diff options
Diffstat (limited to 'Lib/threading.py')
| -rw-r--r-- | Lib/threading.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/Lib/threading.py b/Lib/threading.py index 61c25b6534..1aed551c5f 100644 --- a/Lib/threading.py +++ b/Lib/threading.py @@ -358,7 +358,7 @@ def _newname(template="Thread-%d"): # Active thread administration _active_limbo_lock = _allocate_lock() -_active = {} +_active = {} # maps thread id to Thread object _limbo = {} @@ -643,8 +643,9 @@ def _pickSomeNonDaemonThread(): # Dummy thread class to represent threads not started here. -# These aren't garbage collected when they die, -# nor can they be waited for. +# These aren't garbage collected when they die, nor can they be waited for. +# If they invoke anything in threading.py that calls currentThread(), they +# leave an entry in the _active dict forever after. # Their purpose is to return *something* from currentThread(). # They are marked as daemon threads so we won't wait for them # when we exit (conform previous semantics). @@ -653,7 +654,12 @@ class _DummyThread(Thread): def __init__(self): Thread.__init__(self, name=_newname("Dummy-%d")) + + # Thread.__block consumes an OS-level locking primitive, which + # can never be used by a _DummyThread. Since a _DummyThread + # instance is immortal, that's bad, so release this resource. del self._Thread__block + self._Thread__started = True _active_limbo_lock.acquire() _active[_get_ident()] = self |
