From 46b6b4037d08c175348304c0dbc24d606ac8ae4e Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Tue, 10 Jan 2017 10:55:46 -0500 Subject: [PATCH] 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 --- klippy/reactor.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/klippy/reactor.py b/klippy/reactor.py index d27635ff..1adf09a8 100644 --- a/klippy/reactor.py +++ b/klippy/reactor.py @@ -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