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.

classification
Title: ensure lock is released if exception is raised
Type: Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: brett.cannon Nosy List: brett.cannon, eblossom
Priority: normal Keywords: patch

Created on 2005-10-06 02:18 by eblossom, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
python.patch eblossom, 2005-10-06 02:18 patch to dist/src/Lib/threading.py
Messages (2)
msg48842 - (view) Author: Eric Blossom (eblossom) Date: 2005-10-06 02:18
If an exception (typically KeyboardInterrupt) is raised
in Thread.join, self.__block will be left locked, and
any later attempt to join will block forever.  The bug
is easy to trigger if you provide a timeout to join. 
This patch ensures that the lock is released.
msg48843 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2005-11-23 02:22
Logged In: YES 
user_id=357491

rev. 41524 (2.5) and rev. 41525 (2.4) have the fix.  I am
really looking forward to the 'with' statement and having
all of the locks in 'threading' support it.  Then this kind
of thing will be avoided.

Also, so it is documented, to trigger this, do the following::

import threading
import time

th = threading.Thread(target=lambda: time.sleep(5.0))
th.start()
th.join('blah')
th.join  # Used to hang

Thanks, Eric (tacked you on to Misc/ACKS).
History
Date User Action Args
2022-04-11 14:56:13adminsetgithub: 42453
2005-10-06 02:18:54eblossomcreate