summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-01-13 16:14:44 +0100
committerVictor Stinner <victor.stinner@gmail.com>2015-01-13 16:14:44 +0100
commitd2cafa0a613a054c0696151c88950be4dad5933d (patch)
tree042a89cb62d69104f82204402eff9785a0f5aea6
parentd9072d48f9204c9554abe1413ecd3046b6d6faf0 (diff)
downloadtrollius-git-d2cafa0a613a054c0696151c88950be4dad5933d.tar.gz
Python 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.
-rw-r--r--asyncio/proactor_events.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/asyncio/proactor_events.py b/asyncio/proactor_events.py
index 0a4d068..5986e37 100644
--- a/asyncio/proactor_events.py
+++ b/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)