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

Commit0473fe7

Browse files
gvanrossummiss-islington
authored andcommitted
pythonGH-96827: Don't touch closed loops from executor threads (pythonGH-96837)
* When chaining futures, skip callback if loop closed.* When shutting down an executor, don't wake a closed loop.(cherry picked from commite9d6376)Co-authored-by: Guido van Rossum <guido@python.org>
1 parent6d7dbcc commit0473fe7

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

‎Lib/asyncio/base_events.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -573,9 +573,11 @@ async def shutdown_default_executor(self):
573573
def_do_shutdown(self,future):
574574
try:
575575
self._default_executor.shutdown(wait=True)
576-
self.call_soon_threadsafe(future.set_result,None)
576+
ifnotself.is_closed():
577+
self.call_soon_threadsafe(future.set_result,None)
577578
exceptExceptionasex:
578-
self.call_soon_threadsafe(future.set_exception,ex)
579+
ifnotself.is_closed():
580+
self.call_soon_threadsafe(future.set_exception,ex)
579581

580582
def_check_running(self):
581583
ifself.is_running():

‎Lib/asyncio/futures.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,8 @@ def _call_set_state(source):
396396
ifdest_loopisNoneordest_loopissource_loop:
397397
_set_state(destination,source)
398398
else:
399+
ifdest_loop.is_closed():
400+
return
399401
dest_loop.call_soon_threadsafe(_set_state,destination,source)
400402

401403
destination.add_done_callback(_call_check_cancel)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Avoid spurious tracebacks from:mod:`asyncio` when default executor cleanup is delayed until after the event loop is closed (e.g. as the result of a keyboard interrupt).

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp