Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbc61315

Browse files
authored
bpo-31249: Fix ref cycle in ThreadPoolExecutor (#3178)
*bpo-31249: Fix ref cycle in ThreadPoolExecutorconcurrent.futures: WorkItem.run() used by ThreadPoolExecutor nowbreaks a reference cycle between an exception object and the WorkItemobject. ThreadPoolExecutor.shutdown() now also clears its threadsset.* shutdown() now only clears threads if wait is true.* Revert changes on shutdown()
1 parent5fe59f8 commitbc61315

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

‎Lib/concurrent/futures/thread.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,10 @@ def run(self):
5454

5555
try:
5656
result=self.fn(*self.args,**self.kwargs)
57-
exceptBaseExceptionase:
58-
self.future.set_exception(e)
57+
exceptBaseExceptionasexc:
58+
self.future.set_exception(exc)
59+
# Break a reference cycle with the exception 'exc'
60+
self=None
5961
else:
6062
self.future.set_result(result)
6163

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
concurrent.futures: WorkItem.run() used by ThreadPoolExecutor now breaks a
2+
reference cycle between an exception object and the WorkItem object.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2026 Movatter.jp