From 14062d743be20d7424c5c27bc03819a89dfd6fca Mon Sep 17 00:00:00 2001 From: Chris Meyer Date: Fri, 29 May 2020 16:54:11 -0700 Subject: [PATCH] bpo-39010: Ignore error on cancelled future after end of loop. --- Lib/asyncio/proactor_events.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Lib/asyncio/proactor_events.py b/Lib/asyncio/proactor_events.py index 8338449aaa0a3e..55a031ab47bc8d 100644 --- a/Lib/asyncio/proactor_events.py +++ b/Lib/asyncio/proactor_events.py @@ -765,7 +765,14 @@ def _make_self_pipe(self): def _loop_self_reading(self, f=None): try: if f is not None: - f.result() # may raise + try: + f.result() # may raise + except ConnectionResetError: + # when run_forever exits, the done callback added at + # the end of this function may still be pending and a subclass + # may have also cancelled the future. this will result in a + # spurious ConnectionResetError. ignore that error. + pass f = self._proactor.recv(self._ssock, 4096) except exceptions.CancelledError: # _close_self_pipe() has been called, stop waiting for data