Tim Peters <[email protected]> added the comment:
>> is there a bulletproof way to guarantee that `self._stop()` gets
>> called if the acquire_and_release() succeeds?
> I don't think it's critical.
Agreed! Anything at the Python level that cares whether the thread is still
alive will call _wait_for_tstate_lock() again, and get another chance each time
to notice that the tstate lock has been freed.
Instead of:
try:
if lock.acquire_and_release(block, timeout):
self._stop
except:
if not lock.locked():
self._stop()
I'd prefer:
try:
lock.acquire_and_release(block, timeout)
finally:
if not lock.locked():
self._stop()
Because, at the Python level, whether acquire_and_release() succeeded at its
task depends entirely on whether the lock is free afterward. That's what we're
_really_ looking for, and is so on all possible platforms.
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue46726>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com