8000 Issue #22922: Fix ProactorEventLoop.close() · python/cpython@4c85ec9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4c85ec9

Browse files
committed
Issue #22922: Fix ProactorEventLoop.close()
Call _stop_accept_futures() before sestting the _closed attribute, otherwise call_soon() raises an error.
1 parent e80bf0d commit 4c85ec9

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Lib/asyncio/proactor_events.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,11 +387,13 @@ def _make_write_pipe_transport(self, sock, protocol, waiter=None,
387387
sock, protocol, waiter, extra)
388388

389389
def close(self):
390+
if self._running:
391+
raise RuntimeError("Cannot close a running event loop")
390392
if self.is_closed():
391393
return
392-
super().close()
393394
self._stop_accept_futures()
394395
self._close_self_pipe()
396+
super().close()
395397
self._proactor.close()
396398
self._proactor = None
397399
self._selector = None

0 commit comments

Comments
 (0)
0