[Python-checkins] cpython (3.4): asyncio: BaseSelectorEventLoop.close() now closes the self-pipe before calling

victor.stinner python-checkins at python.org
Fri Nov 21 00:25:07 CET 2014


https://hg.python.org/cpython/rev/a08c3703f844
changeset:   93522:a08c3703f844
branch:      3.4
parent:      93519:1b5d23a4a5fd
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Fri Nov 21 00:23:27 2014 +0100
summary:
  asyncio: BaseSelectorEventLoop.close() now closes the self-pipe before calling
the parent close() method. If the event loop is already closed, the self-pipe
is not unregistered from the selector.

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


diff --git a/Lib/asyncio/selector_events.py b/Lib/asyncio/selector_events.py
--- a/Lib/asyncio/selector_events.py
+++ b/Lib/asyncio/selector_events.py
@@ -68,10 +68,12 @@
                                           address, waiter, extra)
 
     def close(self):
+        if self._running:
+            raise RuntimeError("Cannot close a running event loop")
         if self.is_closed():
             return
+        self._close_self_pipe()
         super().close()
-        self._close_self_pipe()
         if self._selector is not None:
             self._selector.close()
             self._selector = None

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


More information about the Python-checkins mailing list