commit 5055f3c8725baa4b2e0dc522259c5673d27ad92a
parent 4a64b4f07b4bb56a8e7d560f543a99d8ae92bf65
Author: Joris Vink <joris@coders.se>
Date: Sun, 16 Jun 2019 19:57:48 +0200
add kore.worker() to the python api.
returns the current worker number or None if on parent.
Diffstat:
2 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/include/kore/python_methods.h b/include/kore/python_methods.h
@@ -40,6 +40,7 @@ static PyObject *python_kore_bind(PyObject *, PyObject *);
static PyObject *python_kore_timer(PyObject *, PyObject *);
static PyObject *python_kore_fatal(PyObject *, PyObject *);
static PyObject *python_kore_queue(PyObject *, PyObject *);
+static PyObject *python_kore_worker(PyObject *, PyObject *);
static PyObject *python_kore_tracer(PyObject *, PyObject *);
static PyObject *python_kore_fatalx(PyObject *, PyObject *);
static PyObject *python_kore_suspend(PyObject *, PyObject *);
@@ -74,6 +75,7 @@ static struct PyMethodDef pykore_methods[] = {
METHOD("bind", python_kore_bind, METH_VARARGS),
METHOD("timer", python_kore_timer, METH_VARARGS),
METHOD("queue", python_kore_queue, METH_VARARGS),
+ METHOD("worker", python_kore_worker, METH_VARARGS),
METHOD("tracer", python_kore_tracer, METH_VARARGS),
METHOD("gather", python_kore_gather, METH_VARARGS | METH_KEYWORDS),
METHOD("fatal", python_kore_fatal, METH_VARARGS),
diff --git a/src/python.c b/src/python.c
@@ -1252,6 +1252,16 @@ python_kore_queue(PyObject *self, PyObject *args)
}
static PyObject *
+python_kore_worker(PyObject *self, PyObject *args)
+{
+ if (worker == NULL) {
+ Py_RETURN_NONE;
+ }
+
+ return (PyLong_FromLong(worker->id));
+}
+
+static PyObject *
python_kore_tracer(PyObject *self, PyObject *args)
{
PyObject *obj;