summaryrefslogtreecommitdiff
path: root/Lib/asyncio/proactor_events.py
diff options
context:
space:
mode:
authorBen Darnell <ben@bendarnell.com>2020-08-31 15:57:52 -0400
committerGitHub <noreply@github.com>2020-08-31 12:57:52 -0700
commitea5a6363c3f8cc90b7c0cc573922b10f296073b6 (patch)
tree9464334a7c5d9f0b5dc76a227b915a9850d05c90 /Lib/asyncio/proactor_events.py
parentc3a651ad2544d7d1be389b63e9a4a58a92a31623 (diff)
downloadcpython-git-ea5a6363c3f8cc90b7c0cc573922b10f296073b6.tar.gz
bpo-39010: Fix errors logged on proactor loop restart (#22017)
Stopping and restarting a proactor event loop on windows can lead to spurious errors logged (ConnectionResetError while reading from the self pipe). This fixes the issue by ensuring that we don't attempt to start multiple copies of the self-pipe reading loop.
Diffstat (limited to 'Lib/asyncio/proactor_events.py')
-rw-r--r--Lib/asyncio/proactor_events.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/asyncio/proactor_events.py b/Lib/asyncio/proactor_events.py
index d0b7100f5e..4670bd683a 100644
--- a/Lib/asyncio/proactor_events.py
+++ b/Lib/asyncio/proactor_events.py
@@ -768,6 +768,14 @@ class BaseProactorEventLoop(base_events.BaseEventLoop):
try:
if f is not None:
f.result() # may raise
+ if self._self_reading_future is not f:
+ # When we scheduled this Future, we assigned it to
+ # _self_reading_future. If it's not there now, something has
+ # tried to cancel the loop while this callback was still in the
+ # queue (see windows_events.ProactorEventLoop.run_forever). In
+ # that case stop here instead of continuing to schedule a new
+ # iteration.
+ return
f = self._proactor.recv(self._ssock, 4096)
except exceptions.CancelledError:
# _close_self_pipe() has been called, stop waiting for data