libev: service timeouts before updating loop timer.
Also, never start a timer with zero repeat (this causes it to stop, rather than timeout immediately).
This commit is contained in:
@@ -148,6 +148,7 @@ class LibevLoop(object):
|
|||||||
|
|
||||||
def _update_timer(self):
|
def _update_timer(self):
|
||||||
if not self._shutdown:
|
if not self._shutdown:
|
||||||
|
self._timers.service_timeouts()
|
||||||
offset = self._timers.next_offset or 100000 # none pending; will be updated again when something new happens
|
offset = self._timers.next_offset or 100000 # none pending; will be updated again when something new happens
|
||||||
self._loop_timer.start(offset)
|
self._loop_timer.start(offset)
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -517,7 +517,9 @@ Timer_start(libevwrapper_Timer *self, PyObject *args) {
|
|||||||
if (!PyArg_ParseTuple(args, "d", &timeout)) {
|
if (!PyArg_ParseTuple(args, "d", &timeout)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
self->timer.repeat = fmax(timeout, 0.0);
|
/* some tiny non-zero number to avoid zero, and
|
||||||
|
make it run immediately for negative timeouts */
|
||||||
|
self->timer.repeat = fmax(timeout, 0.000000001);
|
||||||
ev_timer_again(self->loop->loop, &self->timer);
|
ev_timer_again(self->loop->loop, &self->timer);
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user