diff --git a/cassandra/io/libevreactor.py b/cassandra/io/libevreactor.py index 31c9cd38..e6abb76b 100644 --- a/cassandra/io/libevreactor.py +++ b/cassandra/io/libevreactor.py @@ -148,6 +148,7 @@ class LibevLoop(object): def _update_timer(self): 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 self._loop_timer.start(offset) else: diff --git a/cassandra/io/libevwrapper.c b/cassandra/io/libevwrapper.c index 1c52a964..99e1df30 100644 --- a/cassandra/io/libevwrapper.c +++ b/cassandra/io/libevwrapper.c @@ -517,7 +517,9 @@ Timer_start(libevwrapper_Timer *self, PyObject *args) { if (!PyArg_ParseTuple(args, "d", &timeout)) { 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); Py_RETURN_NONE; }