Skip to content
Closed
Prev Previous commit
Next Next commit
Be more specific in _wait_for_tstate_lock().
  • Loading branch information
ericsnowcurrently committed May 16, 2023
commit de530b173522da45ecc6e0520915581d01eabe54
7 changes: 4 additions & 3 deletions Lib/threading.py
Original file line number Diff line number Diff line change
Expand Up @@ -1144,9 +1144,7 @@ def _wait_for_tstate_lock(self, block=True, timeout=-1):
return

try:
if lock.acquire(block, timeout):
lock.release()
self._stop()
locked = lock.acquire(block, timeout)
except:
if lock.locked():
# bpo-45274: lock.acquire() acquired the lock, but the function
Expand All @@ -1156,6 +1154,9 @@ def _wait_for_tstate_lock(self, block=True, timeout=-1):
lock.release()
self._stop()
raise
if locked:
lock.release()
self._stop()

@property
def name(self):
Expand Down