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 f2472ba48558427fb99ac5f2e555947b22c4bb74
parent 88bd3ce045329590611b7985b75b850abd77768f
Author: Joris Vink <joris@coders.se>
Date:   Wed,  4 Sep 2019 20:37:33 +0200

allow python modules to set progname.

Diffstat:
include/kore/python_methods.h | 2++
src/cli.c | 3+++
src/python.c | 15+++++++++++++++
3 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/include/kore/python_methods.h b/include/kore/python_methods.h @@ -43,6 +43,7 @@ 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_setname(PyObject *, PyObject *); static PyObject *python_kore_suspend(PyObject *, PyObject *); static PyObject *python_kore_shutdown(PyObject *, PyObject *); static PyObject *python_kore_bind_unix(PyObject *, PyObject *); @@ -82,6 +83,7 @@ static struct PyMethodDef pykore_methods[] = { METHOD("gather", python_kore_gather, METH_VARARGS | METH_KEYWORDS), METHOD("fatal", python_kore_fatal, METH_VARARGS), METHOD("fatalx", python_kore_fatalx, METH_VARARGS), + METHOD("setname", python_kore_setname, METH_VARARGS), METHOD("suspend", python_kore_suspend, METH_VARARGS), METHOD("shutdown", python_kore_shutdown, METH_NOARGS), METHOD("bind_unix", python_kore_bind_unix, METH_VARARGS), diff --git a/src/cli.c b/src/cli.c @@ -335,9 +335,12 @@ static const char *python_config_data = "}\n"; static const char *python_init_data = + "import kore\n" "from .app import koreapp\n" "\n" "def kore_parent_configure(args):\n" + " if hasattr(koreapp, \"_appname\"):\n" + " kore.setname(koreapp._appname)\n" " koreapp.configure(args)\n" "\n" "def kore_worker_configure():\n" diff --git a/src/python.c b/src/python.c @@ -1411,6 +1411,21 @@ python_kore_fatalx(PyObject *self, PyObject *args) } static PyObject * +python_kore_setname(PyObject *self, PyObject *args) +{ + const char *name; + extern char *kore_progname; + + if (!PyArg_ParseTuple(args, "s", &name)) + return (NULL); + + kore_free(kore_progname); + kore_progname = kore_strdup(name); + + Py_RETURN_NONE; +} + +static PyObject * python_kore_suspend(PyObject *self, PyObject *args) { struct pysuspend_op *op;