diff Lib/threading.py @ 66990:c70aa011c059 3.1

Merged revisions 87341 via svnmerge from svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r87341 | antoine.pitrou | 2010-12-17 18:42:16 +0100 (ven., 17 déc. 2010) | 4 lines Issue #4188: Avoid creating dummy thread objects when logging operations from the threading module (with the internal verbose flag activated). ........
author Antoine Pitrou <solipsis@pitrou.net>
date Fri, 17 Dec 2010 17:44:45 +0000
parents c10024abd118
children ad2f34380aac
line wrap: on
line diff
--- a/Lib/threading.py	Fri Dec 17 04:54:43 2010 +0000
+++ b/Lib/threading.py	Fri Dec 17 17:44:45 2010 +0000
@@ -50,8 +50,14 @@
         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: