Friday, 15 April 2011

garbage collection - Without releasing lock in Condition implementation in Python -


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 notification call is removed from the call for the call to stop blocking, therefore In the context of the object it will be to keep alive because there are no live references when 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