当我在threading.py模块的类条件部分中阅读源代码时,我的想法是:如果锁归current_thread.self.self .__ lock.acquire(0)拥有,除非它本身失败,否则返回false。锁定
def _is_owned(self):
# Return True if lock is owned by current_thread.
# This method is called only if __lock doesn't have _is_owned().
if self.__lock.acquire(0):
self.__lock.release()
return False
else:
return True