I have a question about the condition. Here is the source code that I read in thread 339 in line 339. Def wait (self, timeout = none): ... if not self._is_owned (): Increase RuntimeError ("Can not wait on lock received by UN") Waiter = _allocate_lock () waiter.acquire () auto.__ Waiters.append (waiter) saved_state = self._release_save () try: if time is no more: waiter.acquire () # my question here ...
I found that only waiters Receives the release () without having a lock in the call, so does it just allow Python GC to destroy the waiter? Is that good?
Yes, for that specific case - waiter.acquire ()
No timeout
is specified - waiter
as soon as the object runs wait
; waiter.acquire ()
for wait
is complete, therefore the waste collector will destroy the entire object, i.e. there is no reason to explicitly release the lock is.
No comments:
Post a Comment