[Python-checkins] python/dist/src/Lib threading.py,1.46,1.47
tim_one at users.sourceforge.net
tim_one at users.sourceforge.net
Sat Jan 8 08:30:45 CET 2005
Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21399/Lib
Modified Files:
threading.py
Log Message:
threading._DummyThread.__init__(): document obscure new code.
test_threading.test_foreign_thread(): new test does a basic check that
"foreign" threads can using the threading module, and that they create
a _DummyThread instance in at least one use case. This isn't a very
good test, since a thread created by thread.start_new_thread() isn't
particularly "foreign".
Index: threading.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/threading.py,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- threading.py 8 Jan 2005 02:43:51 -0000 1.46
+++ threading.py 8 Jan 2005 07:30:42 -0000 1.47
@@ -358,7 +358,7 @@
# Active thread administration
_active_limbo_lock = _allocate_lock()
-_active = {}
+_active = {} # maps thread id to Thread object
_limbo = {}
@@ -643,8 +643,9 @@
# 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 @@
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
More information about the Python-checkins
mailing list