summaryrefslogtreecommitdiffstats
path: root/Lib/threading.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2011-07-15 20:15:38 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2011-07-15 20:15:38 (GMT)
commit428bc6c48f41123149ddf1c3589fbe548cc38c48 (patch)
tree80f470fa46e60653994c790718621b2dfb56c580 /Lib/threading.py
parent91fe8157fd3518fcf7c2f7cd7bd247131e8e839f (diff)
parentc081c0c6a0c917de72b7d7944c5316174717d56d (diff)
downloadcpython-428bc6c48f41123149ddf1c3589fbe548cc38c48.zip
cpython-428bc6c48f41123149ddf1c3589fbe548cc38c48.tar.gz
cpython-428bc6c48f41123149ddf1c3589fbe548cc38c48.tar.bz2
Issue #12573: Add resource checks for dangling Thread and Process objects.
Diffstat (limited to 'Lib/threading.py')
-rw-r--r--Lib/threading.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/threading.py b/Lib/threading.py
index 1f638b4..9681f02 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
@@ -608,6 +609,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
@@ -645,6 +648,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