summaryrefslogtreecommitdiffstats
path: root/Lib/threading.py
diff options
context:
space:
mode:
authorJeffrey Yasskin <jyasskin@gmail.com>2008-02-23 20:40:35 (GMT)
committerJeffrey Yasskin <jyasskin@gmail.com>2008-02-23 20:40:35 (GMT)
commita885c1521a547d728e04bbede8c669417d41b9bb (patch)
tree6ec3939f235ea546701f5d3dafaf0ce1e78f815e /Lib/threading.py
parent3414ea9ed9fce2b9ce74e8b6c7c3b4278b526685 (diff)
downloadcpython-a885c1521a547d728e04bbede8c669417d41b9bb.zip
cpython-a885c1521a547d728e04bbede8c669417d41b9bb.tar.gz
cpython-a885c1521a547d728e04bbede8c669417d41b9bb.tar.bz2
Followup to r61011: Also avoid the reference cycle when the Thread's target
raises an exception.
Diffstat (limited to 'Lib/threading.py')
-rw-r--r--Lib/threading.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/Lib/threading.py b/Lib/threading.py
index 2f472b4..005d40c 100644
--- a/Lib/threading.py
+++ b/Lib/threading.py
@@ -442,11 +442,13 @@ class Thread(_Verbose):
_sleep(0.000001) # 1 usec, to let the thread run (Solaris hack)
def run(self):
- if self.__target:
- self.__target(*self.__args, **self.__kwargs)
- # Avoid a refcycle if the thread is running a function with an
- # argument that has a member that points to the thread.
- del self.__target, self.__args, self.__kwargs
+ try:
+ if self.__target:
+ self.__target(*self.__args, **self.__kwargs)
+ finally:
+ # Avoid a refcycle if the thread is running a function with
+ # an argument that has a member that points to the thread.
+ del self.__target, self.__args, self.__kwargs
def __bootstrap(self):
# Wrapper around the real bootstrap code that ignores