]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #4188: Avoid creating dummy thread objects when logging operations
authorAntoine Pitrou <solipsis@pitrou.net>
Fri, 17 Dec 2010 17:42:16 +0000 (17:42 +0000)
committerAntoine Pitrou <solipsis@pitrou.net>
Fri, 17 Dec 2010 17:42:16 +0000 (17:42 +0000)
from the threading module (with the internal verbose flag activated).

Lib/threading.py
Misc/NEWS

index b6c1e5ddab9d63dc194f75cfaf4f12bfc57a4f98..01c27b85e6d68d0b9a0ab7b4fbadde53200de28c 100644 (file)
@@ -55,8 +55,14 @@ if __debug__:
         def _note(self, format, *args):
             if self._verbose:
                 format = format % args
-                format = "%s: %s\n" % (
-                    current_thread().name, format)
+                # Issue #4188: calling current_thread() can incur an infinite
+                # recursion if it has to create a DummyThread on the fly.
+                ident = _get_ident()
+                try:
+                    name = _active[ident].name
+                except KeyError:
+                    name = "<OS thread %d>" % ident
+                format = "%s: %s\n" % (name, format)
                 _sys.stderr.write(format)
 
 else:
index 6e618924abc24d4e37702575e6ce3c3457c34fee..94116ce55a1a97899c06734207c1807464130a91 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -20,6 +20,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #4188: Avoid creating dummy thread objects when logging operations
+  from the threading module (with the internal verbose flag activated).
+
 - Issue #10711: Remove HTTP 0.9 support from http.client.  The ``strict``
   parameter to HTTPConnection and friends is deprecated.