homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author glglgl
Recipients glglgl
Date 2011年03月29日.20:08:04
SpamBayes Score 6.3332764e-06
Marked as misclassified No
Message-id <1301429285.55.0.524593153571.issue11714@psf.upfronthosting.co.za>
In-reply-to
Content
The acquire() and release() functions of threading.Semaphore do not make use of the try...finally suite as it would be reasonable.
They just do 
 def acquire(self, blocking=1):
 rc = False
 self.__cond.acquire()
 [...]
 self.__cond.release()
 return rc
 [...]
 def release(self):
 self.__cond.acquire()
 [...]
 self.__cond.release()
while IMO it would be appropriate to put a try: after the acquire() calls and a finally: before the release() calls so the lock is not held forever if an exception occurs.
(Feel free to use with self.__cond: instead...)
Especially when Ctrl-C is pressed while acquire() waits, the respective KeyboardInterrupt gets thrown after acquire(), breaking the respective function and the __cond is locked forever because it is never release()d.
History
Date User Action Args
2011年03月29日 20:08:05glglglsetrecipients: + glglgl
2011年03月29日 20:08:05glglglsetmessageid: <1301429285.55.0.524593153571.issue11714@psf.upfronthosting.co.za>
2011年03月29日 20:08:05glglgllinkissue11714 messages
2011年03月29日 20:08:04glglglcreate

AltStyle によって変換されたページ (->オリジナル) /