Commit 4e41d09d authored by Denis Bilenko's avatar Denis Bilenko

before starting a timer, update libev's cached time

- this can be overriden by passing update=True to start() method
- again() method is updated as well
- see issue 97: code.google.com/p/gevent/issues/detail?id=97
parent 8a5f59e3
......@@ -643,7 +643,18 @@ cdef public class io(watcher) [object PyGeventIOObject, type PyGeventIO_Type]:
cdef public class timer(watcher) [object PyGeventTimerObject, type PyGeventTimer_Type]:
WATCHER(timer)
WATCHER_BASE(timer)
def start(self, object callback, *args, update=True):
self.callback = callback
self.args = args
LIBEV_UNREF
if update:
libev.ev_now_update(self.loop._ptr)
libev.ev_timer_start(self.loop._ptr, &self._watcher)
PYTHON_INCREF
ACTIVE
INIT(timer, COMMA double after=0.0 COMMA double repeat=0.0, COMMA after COMMA repeat)
......@@ -652,10 +663,12 @@ cdef public class timer(watcher) [object PyGeventTimerObject, type PyGeventTimer
def __get__(self):
return self._watcher.at
def again(self, object callback, *args):
def again(self, object callback, *args, update=True):
self.callback = callback
self.args = args
LIBEV_UNREF
if update:
libev.ev_now_update(self.loop._ptr)
libev.ev_timer_again(self.loop._ptr, &self._watcher)
PYTHON_INCREF
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment