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 1db3cd96d85a242100fe98456f40c3743dd9c106
parent 2c66dfa3cfe858855cced99738886ff66f7c50f6
Author: Joris Vink <joris@coders.se>
Date:   Thu, 26 Jan 2017 11:13:09 +0100

allow reloading of python modules on SIGHUP.

Diffstat:
src/python.c | 17+++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/python.c b/src/python.c @@ -200,19 +200,20 @@ python_module_free(struct kore_module *module) static void python_module_reload(struct kore_module *module) { - /* Calls through to kore_python_module_load() below. */ - module->fun->load(module, module->onload); + PyObject *handle; + + if ((handle = PyImport_ReloadModule(module->handle)) == NULL) { + python_log_error("python_module_reload"); + return; + } + + Py_DECREF(module->handle); + module->handle = handle; } static void python_module_load(struct kore_module *module, const char *onload) { - if (module->handle != NULL) - Py_DECREF(module->handle); - - kore_python_cleanup(); - kore_python_init(); - module->handle = python_import(module->path); if (module->handle == NULL) fatal("%s: failed to import module", module->path);