diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2014-11-20 01:00:50 +0100 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2014-11-20 01:00:50 +0100 |
commit | 8a47c5476004181b801ba417f4fe3258555a19f8 (patch) | |
tree | 5da2c9117d710d9f6a6a969fd4060e90843babb4 | |
parent | 35a1d05b171d8b10296457de7a8d252993616f41 (diff) | |
download | aioeventlet-8a47c5476004181b801ba417f4fe3258555a19f8.tar.gz |
Fix EventLoop.stop(): don't stop immediatly, but schedule stopping the event
loop with call_soon()
-rw-r--r-- | README | 2 | ||||
-rw-r--r-- | aiogreen.py | 5 | ||||
-rw-r--r-- | tests/test_callback.py | 4 |
3 files changed, 8 insertions, 3 deletions
@@ -35,6 +35,8 @@ Version 0.2 (development version) * Support eventlet with monkey-patching * sock_connect() is now asynchronous * Add a suite of automated unit tests +* Fix EventLoop.stop(): don't stop immediatly, but schedule stopping the event + loop with call_soon() 2014-11-19: version 0.1 ----------------------- diff --git a/aiogreen.py b/aiogreen.py index 93ef101..42f195b 100644 --- a/aiogreen.py +++ b/aiogreen.py @@ -386,7 +386,7 @@ class EventLoop(BaseEventLoop): # FIXME: optimization, reschedule _run_once() if the cancelled timer # was the next timer - def stop(self): + def _stop(self): if self._stop_event is None: # not running return @@ -395,6 +395,9 @@ class EventLoop(BaseEventLoop): return self._stop_event.send("stop") + def stop(self): + self.call_soon(self._stop) + def run_forever(self): if self._stop_event is not None: raise RuntimeError("reentrant call to run_forever()") diff --git a/tests/test_callback.py b/tests/test_callback.py index 5b306de..1bf30bb 100644 --- a/tests/test_callback.py +++ b/tests/test_callback.py @@ -24,10 +24,10 @@ class CallbackTests(tests.TestCase): self.loop.stop() self.loop.call_soon(hello) - self.loop.call_soon(self.loop.stop) + self.loop.stop() self.loop.call_soon(world) - self.loop.run_forever() + self.loop.run_forever() self.assertEqual(result, ["Hello"]) self.loop.run_forever() |