reactor: Reload eventtime if a greenlet is reactivated
Fix a bug causing timers to be delayed when pause() is called from a fd event. The eventtime needs to be reloaded when an old greenlet is reactivated. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
93d3a6e1d1
commit
46b6b4037d
|
@ -106,6 +106,7 @@ class SelectReactor:
|
|||
fd.callback(eventtime)
|
||||
if g_dispatch is not self._g_dispatch:
|
||||
self._end_greenlet(g_dispatch)
|
||||
eventtime = time.time()
|
||||
break
|
||||
self._g_dispatch = None
|
||||
def run(self):
|
||||
|
@ -138,13 +139,14 @@ class PollReactor(SelectReactor):
|
|||
self._g_dispatch = g_dispatch = greenlet.getcurrent()
|
||||
eventtime = time.time()
|
||||
while self._process:
|
||||
timeout = int(math.ceil(self._check_timers(eventtime) * 1000.))
|
||||
res = self._poll.poll(timeout)
|
||||
timeout = self._check_timers(eventtime)
|
||||
res = self._poll.poll(int(math.ceil(timeout * 1000.)))
|
||||
eventtime = time.time()
|
||||
for fd, event in res:
|
||||
self._fds[fd](eventtime)
|
||||
if g_dispatch is not self._g_dispatch:
|
||||
self._end_greenlet(g_dispatch)
|
||||
eventtime = time.time()
|
||||
break
|
||||
self._g_dispatch = None
|
||||
|
||||
|
@ -179,6 +181,7 @@ class EPollReactor(SelectReactor):
|
|||
self._fds[fd](eventtime)
|
||||
if g_dispatch is not self._g_dispatch:
|
||||
self._end_greenlet(g_dispatch)
|
||||
eventtime = time.time()
|
||||
break
|
||||
self._g_dispatch = None
|
||||
|
||||
|
|
Loading…
Reference in New Issue