summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/base_events.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2022-09-30 19:55:40 (GMT)
committerGitHub <noreply@github.com>2022-09-30 19:55:40 (GMT)
commite9d63760fea8748638f6e495b5b07bd1805c9591 (patch)
tree26a42e0867b0a7cdc67b39e4f1b44021d95ef36f /Lib/asyncio/base_events.py
parentb05dd796492160c37c9e15e3882f699f411b3461 (diff)
downloadcpython-e9d63760fea8748638f6e495b5b07bd1805c9591.zip
cpython-e9d63760fea8748638f6e495b5b07bd1805c9591.tar.gz
cpython-e9d63760fea8748638f6e495b5b07bd1805c9591.tar.bz2
GH-96827: Don't touch closed loops from executor threads (#96837)
* When chaining futures, skip callback if loop closed. * When shutting down an executor, don't wake a closed loop.
Diffstat (limited to 'Lib/asyncio/base_events.py')
-rw-r--r--Lib/asyncio/base_events.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py
index 9c9d98d..2df9dca 100644
--- a/Lib/asyncio/base_events.py
+++ b/Lib/asyncio/base_events.py
@@ -588,9 +588,11 @@ class BaseEventLoop(events.AbstractEventLoop):
def _do_shutdown(self, future):
try:
self._default_executor.shutdown(wait=True)
- self.call_soon_threadsafe(future.set_result, None)
+ if not self.is_closed():
+ self.call_soon_threadsafe(future.set_result, None)
except Exception as ex:
- self.call_soon_threadsafe(future.set_exception, ex)
+ if not self.is_closed():
+ self.call_soon_threadsafe(future.set_exception, ex)
def _check_running(self):
if self.is_running():