From 82b6b136ed8fd5bc7c503eeaed3ed52944e5e7ff Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 21 Nov 2014 04:56:41 +0100 Subject: _Selector.select() doesn't use polling anymore --- aiogreen.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/aiogreen.py b/aiogreen.py index 9ec1912..f2ee377 100644 --- a/aiogreen.py +++ b/aiogreen.py @@ -159,12 +159,15 @@ class _Selector(asyncio.selectors._BaseSelectorImpl): self._event = eventlet.event.Event() try: if timeout is not None: - # FIXME: don't use polling - endtime = self._loop.time() + timeout - while self._loop.time() <= endtime: - if self._event.ready(): - break - eventlet.sleep(0.010) + def timeout_cb(event): + if event.ready(): + return + event.send('timeout') + + eventlet.spawn_after(timeout, timeout_cb, self._event) + + self._event.wait() + # FIXME: cancel the timeout_cb if wait() returns 'ready'? else: # blocking call self._event.wait() -- cgit v1.2.1