mirror of https://git.kore.io/kore.git
allow reloading of python modules on SIGHUP.
This commit is contained in:
parent
2c66dfa3cf
commit
1db3cd96d8
17
src/python.c
17
src/python.c
|
@ -200,19 +200,20 @@ python_module_free(struct kore_module *module)
|
||||||
static void
|
static void
|
||||||
python_module_reload(struct kore_module *module)
|
python_module_reload(struct kore_module *module)
|
||||||
{
|
{
|
||||||
/* Calls through to kore_python_module_load() below. */
|
PyObject *handle;
|
||||||
module->fun->load(module, module->onload);
|
|
||||||
|
if ((handle = PyImport_ReloadModule(module->handle)) == NULL) {
|
||||||
|
python_log_error("python_module_reload");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Py_DECREF(module->handle);
|
||||||
|
module->handle = handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
python_module_load(struct kore_module *module, const char *onload)
|
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);
|
module->handle = python_import(module->path);
|
||||||
if (module->handle == NULL)
|
if (module->handle == NULL)
|
||||||
fatal("%s: failed to import module", module->path);
|
fatal("%s: failed to import module", module->path);
|
||||||
|
|
Loading…
Reference in New Issue