]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
asyncio: Document EventLoop.close().
authorGuido van Rossum <guido@dropbox.com>
Fri, 1 Nov 2013 21:19:04 +0000 (14:19 -0700)
committerGuido van Rossum <guido@dropbox.com>
Fri, 1 Nov 2013 21:19:04 +0000 (14:19 -0700)
Lib/asyncio/base_events.py
Lib/asyncio/events.py
Lib/test/test_asyncio/test_events.py

index f18a5565706853e53d4909167c701b9d71d57dc5..6e409eadc4cb815646fa003adf3114ffafa3654f 100644 (file)
@@ -186,6 +186,11 @@ class BaseEventLoop(events.AbstractEventLoop):
         self.call_soon(_raise_stop_error)
 
     def close(self):
+        """Close the event loop.
+
+        This clears the queues and shuts down the executor,
+        but does not wait for the executor to finish.
+        """
         self._ready.clear()
         self._scheduled.clear()
         executor = self._default_executor
index a47253a699c64f618012f0d2db9d3fb722cdc2af..7ebc3cb4f3e86afe1cfd056d7d3297154232301b 100644 (file)
@@ -137,6 +137,17 @@ class AbstractEventLoop:
         """Return whether the event loop is currently running."""
         raise NotImplementedError
 
+    def close(self):
+        """Close the loop.
+
+        The loop should not be running.
+
+        This is idempotent and irreversible.
+
+        No other methods should be called after this one.
+        """
+        raise NotImplementedError
+
     # Methods scheduling callbacks.  All these return Handles.
 
     def call_soon(self, callback, *args):
@@ -214,6 +225,8 @@ class AbstractEventLoop:
                                  family=0, proto=0, flags=0):
         raise NotImplementedError
 
+    # Pipes and subprocesses.
+
     def connect_read_pipe(self, protocol_factory, pipe):
         """Register read pipe in eventloop.
 
index fd2af2e1eb8badba12404bb2318575b1858b7e3c..83d73973deda7734d3b432c33b207a7615de5bcd 100644 (file)
@@ -1471,6 +1471,8 @@ class AbstractEventLoopTests(unittest.TestCase):
             NotImplementedError, loop.stop)
         self.assertRaises(
             NotImplementedError, loop.is_running)
+        self.assertRaises(
+            NotImplementedError, loop.close)
         self.assertRaises(
             NotImplementedError, loop.call_later, None, None)
         self.assertRaises(