diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2014-11-21 14:42:31 +0100 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2014-11-21 14:42:31 +0100 |
commit | 4924c1d54108f833b4c498fa2e09412ffad0a626 (patch) | |
tree | 9d27b264d80ca613c14c9ec3eca4644187286909 /aiogreen.py | |
parent | 9426e8154b7e9a4477cfa804f8219edaf68ddad3 (diff) | |
download | aioeventlet-4924c1d54108f833b4c498fa2e09412ffad0a626.tar.gz |
Rewrite call_soon & call_at: call the parent method, and call _write_to_self()
if needed; instead of calling call_soon_threadsafe()
Diffstat (limited to 'aiogreen.py')
-rw-r--r-- | aiogreen.py | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/aiogreen.py b/aiogreen.py index 88bdab3..b5d9647 100644 --- a/aiogreen.py +++ b/aiogreen.py @@ -201,22 +201,20 @@ class EventLoop(asyncio.SelectorEventLoop): self._default_executor = _TpoolExecutor(self) def call_soon(self, callback, *args): + handle = super(EventLoop, self).call_soon(callback, *args) if self._selector._event: - # selector.select() is running: use the thread-safe version to wake - # up select(). - return self.call_soon_threadsafe(callback, *args) - else: - # Fast-path: no need to wake up th eevent loop. - return super(EventLoop, self).call_soon(callback, *args) + # selector.select() is running: write into the self-pipe to wake up + # the selector + self._write_to_self() + return handle def call_at(self, when, callback, *args): + handle = super(EventLoop, self).call_at(when, callback, *args) if self._selector._event: - # selector.select() is running: use the thread-safe version to wake - # up select(). - return self.call_soon_threadsafe(super(EventLoop, self).call_at, when, callback, *args) - else: - # Fast-path: no need to wake up th eevent loop. - return super(EventLoop, self).call_at(when, callback, *args) + # selector.select() is running: write into the self-pipe to wake up + # the selector + self._write_to_self() + return handle def set_debug(self, debug): super(EventLoop, self).set_debug(debug) |