py_tevent: add_timer takes float argument
[kai/samba-autobuild/.git] / lib / tevent / pytevent.c
index 10d8a22a8cff22c4f42463815c24cd6c6197d26f..97976df32d3810a29e3c2fcfecce01590233764c 100644 (file)
@@ -188,7 +188,7 @@ static PyObject *py_register_backend(PyObject *self, PyObject *args)
                return NULL;
        }
 
-       if (!PyStr_Check(name)) {
+       if (!(PyStr_Check(name) || PyUnicode_Check(name))) {
                PyErr_SetNone(PyExc_TypeError);
                Py_DECREF(name);
                return NULL;
@@ -478,9 +478,13 @@ static PyObject *py_tevent_context_add_timer(TeventContext_Object *self, PyObjec
 {
        struct timeval next_event;
        PyObject *callback;
-       if (!PyArg_ParseTuple(args, "lO", &next_event, &callback))
+       double secs, usecs;
+       if (!PyArg_ParseTuple(args, "dO", &secs, &callback)){
                return NULL;
-
+       }
+       next_event.tv_sec = secs;
+       usecs = (secs - next_event.tv_sec) * 1000000.0;
+       next_event.tv_usec = usecs;
        return py_tevent_context_add_timer_internal(self, next_event, callback);
 }