Mercurial > cpython-lru_cache-weakref
diff Lib/threading.py @ 71361:2bedea96de60 3.2
Issue #12573: Add resource checks for dangling Thread and Process objects.
| author | Antoine Pitrou <solipsis@pitrou.net> |
|---|---|
| date | Fri, 15 Jul 2011 22:12:24 +0200 |
| parents | 3c9232a684ae |
| children | e19ccbbe70dd 86dc49fbf4af |
line wrap: on
line diff
--- a/Lib/threading.py Fri Jul 15 21:19:02 2011 +0200 +++ b/Lib/threading.py Fri Jul 15 22:12:24 2011 +0200 @@ -6,6 +6,7 @@ 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 = {} # maps thread id to Thread object _limbo = {} +# For debug and leak testing +_dangling = WeakSet() # Main class for threads @@ -640,6 +643,7 @@ # 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
