[Python-3000] Exception tracebacks living too long in 3.0

Jeffrey Yasskin jyasskin at gmail.com
Sat Mar 29 06:15:19 CET 2008


If you apply the following patch to the py3k branch, you can watch
test_threading fail in test_no_refcycle_through_target:

Index: Lib/threading.py
===================================================================
--- Lib/threading.py    (revision 62033)
+++ Lib/threading.py    (working copy)
@@ -540,6 +540,7 @@
         finally:
             with _active_limbo_lock:
                 self._stop()
+                _sleep(0.01)
                 try:
                     # We don't call self.__delete() because it also
                     # grabs _active_limbo_lock.


This apparently happens because the traceback in sys.exc_info keeps
the frame for the call to RunSelfFunction._run alive even though there
are otherwise no references to the object. In 2.6, this is fixed by
calling sys.exc_clear() before allowing the thread to be joined, but
that function has gone away in 3.0. I had thought that exc_info was
automatically cleared at the end of any except block that caught an
exception, but apparently that isn't the case. Is this a bug in 3.0,
or do we need to keep sys.exc_clear() around?

-- 
Namasté,
Jeffrey Yasskin


More information about the Python-3000 mailing list