diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2015-01-13 15:11:19 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2015-01-13 15:11:19 (GMT) |
commit | b86a96802bf7e054b7b219ee7e9c8fa2444f94d6 (patch) | |
tree | 524fe01998abd910af0e827ea710bd8a69df8396 /Lib | |
parent | 82f34ada45f96c13eb68927d6beccdcbab2c77b3 (diff) | |
download | cpython-b86a96802bf7e054b7b219ee7e9c8fa2444f94d6.zip cpython-b86a96802bf7e054b7b219ee7e9c8fa2444f94d6.tar.gz cpython-b86a96802bf7e054b7b219ee7e9c8fa2444f94d6.tar.bz2 |
Issue #22922: Fix ProactorEventLoop.close()
Close the IocpProactor before closing the event loop. IocpProactor.close() can
call loop.call_soon(), which is forbidden when the event loop is closed.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/asyncio/proactor_events.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Lib/asyncio/proactor_events.py b/Lib/asyncio/proactor_events.py index 0a4d068..5986e37 100644 --- a/Lib/asyncio/proactor_events.py +++ b/Lib/asyncio/proactor_events.py @@ -387,13 +387,19 @@ class BaseProactorEventLoop(base_events.BaseEventLoop): raise RuntimeError("Cannot close a running event loop") if self.is_closed(): return + + # Call these methods before closing the event loop (before calling + # BaseEventLoop.close), because they can schedule callbacks with + # call_soon(), which is forbidden when the event loop is closed. self._stop_accept_futures() self._close_self_pipe() - super().close() self._proactor.close() self._proactor = None self._selector = None + # Close the event loop + super().close() + def sock_recv(self, sock, n): return self._proactor.recv(sock, n) |