mirror of
https://github.com/python/cpython.git
synced 2025-07-31 23:23:11 +00:00
Followup to r61011: Also avoid the reference cycle when the Thread's target
raises an exception.
This commit is contained in:
parent
3414ea9ed9
commit
a885c1521a
2 changed files with 18 additions and 8 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue