[Python-checkins] cpython (3.4): Issue #22922: Fix ProactorEventLoop.close()

victor.stinner python-checkins at python.org
Fri Dec 5 01:45:37 CET 2014


https://hg.python.org/cpython/rev/0a7d956a2f2d
changeset:   93726:0a7d956a2f2d
branch:      3.4
parent:      93723:226f870b387d
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Fri Dec 05 01:43:42 2014 +0100
summary:
  Issue #22922: Fix ProactorEventLoop.close()

Call _stop_accept_futures() before sestting the _closed attribute, otherwise
call_soon() raises an error.

files:
  Lib/asyncio/proactor_events.py |  4 +++-
  1 files changed, 3 insertions(+), 1 deletions(-)


diff --git a/Lib/asyncio/proactor_events.py b/Lib/asyncio/proactor_events.py
--- a/Lib/asyncio/proactor_events.py
+++ b/Lib/asyncio/proactor_events.py
@@ -387,11 +387,13 @@
                                            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

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list