From 4c85ec99f39bb6687f6fb0d23c6a7daedcde990e Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 5 Dec 2014 01:43:42 +0100 Subject: Issue #22922: Fix ProactorEventLoop.close() Call _stop_accept_futures() before sestting the _closed attribute, otherwise call_soon() raises an error. --- Lib/asyncio/proactor_events.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Lib/asyncio/proactor_events.py b/Lib/asyncio/proactor_events.py index a1e2fef..4c527aa 100644 --- a/Lib/asyncio/proactor_events.py +++ b/Lib/asyncio/proactor_events.py @@ -387,11 +387,13 @@ class BaseProactorEventLoop(base_events.BaseEventLoop): sock, protocol, waiter, extra) def close(self): + if self._running: + raise RuntimeError("Cannot close a running event loop") if self.is_closed(): return - super().close() self._stop_accept_futures() self._close_self_pipe() + super().close() self._proactor.close() self._proactor = None self._selector = None -- cgit v0.12