diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2011-07-15 20:12:24 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2011-07-15 20:12:24 (GMT) |
commit | c081c0c6a0c917de72b7d7944c5316174717d56d (patch) | |
tree | 184657849382db7dec5904be11d3d44895f6a16c /Lib/threading.py | |
parent | b8298a01e6fefec9b0b64fd6915e57fc246b9a55 (diff) | |
download | cpython-c081c0c6a0c917de72b7d7944c5316174717d56d.zip cpython-c081c0c6a0c917de72b7d7944c5316174717d56d.tar.gz cpython-c081c0c6a0c917de72b7d7944c5316174717d56d.tar.bz2 |
Issue #12573: Add resource checks for dangling Thread and Process objects.
Diffstat (limited to 'Lib/threading.py')
-rw-r--r-- | Lib/threading.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/threading.py b/Lib/threading.py index fd93f74..d260983 100644 --- a/Lib/threading.py +++ b/Lib/threading.py @@ -6,6 +6,7 @@ import _thread from time import time as _time, sleep as _sleep from traceback import format_exc as _format_exc from collections import deque +from _weakrefset import WeakSet # Note regarding PEP 8 compliant names # This threading model was originally inspired by Java, and inherited @@ -606,6 +607,8 @@ _active_limbo_lock = _allocate_lock() _active = {} # maps thread id to Thread object _limbo = {} +# For debug and leak testing +_dangling = WeakSet() # Main class for threads @@ -640,6 +643,7 @@ class Thread(_Verbose): # sys.stderr is not stored in the class like # sys.exc_info since it can be changed between instances self._stderr = _sys.stderr + _dangling.add(self) def _reset_internal_locks(self): # private! Called by _after_fork() to reset our internal locks as |