This clears the queues and shuts down the executor, but does not wait for
the executor to finish.
+ The event loop must not be running.
+
This is idempotent and irreversible. No other methods should be called after
this one.
This clears the queues and shuts down the executor,
but does not wait for the executor to finish.
+
+ The event loop must not be running.
"""
+ if self._running:
+ raise RuntimeError("cannot close a running event loop")
if self._closed:
return
self._closed = True
def close(self):
if self.is_closed():
return
+ super().close()
self._stop_accept_futures()
self._close_self_pipe()
self._proactor.close()
self._proactor = None
self._selector = None
- super().close()
def sock_recv(self, sock, n):
return self._proactor.recv(sock, n)
def close(self):
if self.is_closed():
return
+ super().close()
self._close_self_pipe()
if self._selector is not None:
self._selector.close()
self._selector = None
- super().close()
def _socketpair(self):
raise NotImplementedError
return socket.socketpair()
def close(self):
+ super().close()
for sig in list(self._signal_handlers):
self.remove_signal_handler(sig)
- super().close()
def add_signal_handler(self, sig, callback, *args):
"""Add a handler for a signal. UNIX only.
with self.assertRaises(RuntimeError):
loop.add_writer(w, callback)
+ def test_close_running_event_loop(self):
+ @asyncio.coroutine
+ def close_loop(loop):
+ self.loop.close()
+
+ coro = close_loop(self.loop)
+ with self.assertRaises(RuntimeError):
+ self.loop.run_until_complete(coro)
+
class SubprocessTestsMixin: