X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fpython.c;h=d2ef1648742e4050aa7b4d645a552d73f3b9a18e;hb=d561993fd1bfb93df203484c4c225aca8b45f041;hp=8bcf82c28d317961f0e0e73e973c27db158480dc;hpb=9bce34a54a0e3268444a9d6d9c484f6bd566f27c;p=collectd.git diff --git a/src/python.c b/src/python.c index 8bcf82c2..d2ef1648 100644 --- a/src/python.c +++ b/src/python.c @@ -656,7 +656,6 @@ static PyObject *cpy_register_read(PyObject *self, PyObject *args, PyObject *kwd double interval = 0; char *name = NULL; PyObject *callback = NULL, *data = NULL; - struct timespec ts; static char *kwlist[] = {"callback", "interval", "data", "name", NULL}; if (PyArg_ParseTupleAndKeywords(args, kwds, "O|dOet", kwlist, &callback, &interval, &data, NULL, &name) == 0) return NULL; @@ -678,10 +677,8 @@ static PyObject *cpy_register_read(PyObject *self, PyObject *args, PyObject *kwd user_data = malloc(sizeof(*user_data)); user_data->free_func = cpy_destroy_user_data; user_data->data = c; - ts.tv_sec = interval; - ts.tv_nsec = (interval - ts.tv_sec) * 1000000000; plugin_register_complex_read(/* group = */ NULL, buf, - cpy_read_callback, &ts, user_data); + cpy_read_callback, DOUBLE_TO_CDTIME_T (interval), user_data); return cpy_string_to_unicode_or_bytes(buf); } @@ -1159,8 +1156,8 @@ static int cpy_config(oconfig_item_t *ci) { cpy_log_exception("python initialization"); continue; } - if (PyList_Append(sys_path, dir_object) != 0) { - ERROR("python plugin: Unable to append \"%s\" to " + if (PyList_Insert(sys_path, 0, dir_object) != 0) { + ERROR("python plugin: Unable to prepend \"%s\" to " "python module path.", dir); cpy_log_exception("python initialization"); }