kore

Kore is a web application platform for writing scalable, concurrent web based processes in C or Python.
Commits | Files | Refs | README | LICENSE | git clone https://git.kore.io/kore.git

commit bc33a5def48d12c8d9459a5faed3b37ad65dc07e
parent ec249390b13d377da8b77d801247cad11ae46ac1
Author: Joris Vink <joris@coders.se>
Date:   Tue, 15 Oct 2019 14:23:49 +0200

Add kore.proc.pid, returns the PID of the proc.

Diffstat:
include/kore/python_methods.h | 8++++++++
src/python.c | 6++++++
2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/include/kore/python_methods.h b/include/kore/python_methods.h @@ -539,10 +539,18 @@ static PyMethodDef pyproc_methods[] = { METHOD(NULL, NULL, -1), }; +static PyObject *pyproc_get_pid(struct pyproc *, void *); + +static PyGetSetDef pyproc_getset[] = { + GETTER("pid", pyproc_get_pid), + GETTER(NULL, NULL), +}; + static PyTypeObject pyproc_type = { PyVarObject_HEAD_INIT(NULL, 0) .tp_name = "kore.proc", .tp_doc = "async process", + .tp_getset = pyproc_getset, .tp_methods = pyproc_methods, .tp_basicsize = sizeof(struct pyproc), .tp_dealloc = (destructor)pyproc_dealloc, diff --git a/src/python.c b/src/python.c @@ -3690,6 +3690,12 @@ pyproc_close_stdin(struct pyproc *proc, PyObject *args) Py_RETURN_TRUE; } +static PyObject * +pyproc_get_pid(struct pyproc *proc, void *closure) +{ + return (PyLong_FromLong(proc->pid)); +} + static void pyproc_op_dealloc(struct pyproc_op *op) {