cpython: asyncio: Document EventLoop.close().

http://hg.python.org/cpython/rev/2ceb3fd38280 changeset: 86829:2ceb3fd38280 user: Guido van Rossum <guido@dropbox.com> date: Fri Nov 01 14:19:04 2013 -0700 summary: asyncio: Document EventLoop.close(). files: Lib/asyncio/base_events.py | 5 +++++ Lib/asyncio/events.py | 13 +++++++++++++ Lib/test/test_asyncio/test_events.py | 2 ++ 3 files changed, 20 insertions(+), 0 deletions(-) diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py --- a/Lib/asyncio/base_events.py +++ b/Lib/asyncio/base_events.py @@ -186,6 +186,11 @@ 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 diff --git a/Lib/asyncio/events.py b/Lib/asyncio/events.py --- a/Lib/asyncio/events.py +++ b/Lib/asyncio/events.py @@ -137,6 +137,17 @@ """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 @@ family=0, proto=0, flags=0): raise NotImplementedError + # Pipes and subprocesses. + def connect_read_pipe(self, protocol_factory, pipe): """Register read pipe in eventloop. diff --git a/Lib/test/test_asyncio/test_events.py b/Lib/test/test_asyncio/test_events.py --- a/Lib/test/test_asyncio/test_events.py +++ b/Lib/test/test_asyncio/test_events.py @@ -1472,6 +1472,8 @@ self.assertRaises( NotImplementedError, loop.is_running) self.assertRaises( + NotImplementedError, loop.close) + self.assertRaises( NotImplementedError, loop.call_later, None, None) self.assertRaises( NotImplementedError, loop.call_at, f, f) -- Repository URL: http://hg.python.org/cpython
participants (1)
-
guido.van.rossum