diff options
author | Max Romanov <max.romanov@nginx.com> | 2020-09-18 13:41:58 +0300 |
---|---|---|
committer | Max Romanov <max.romanov@nginx.com> | 2020-09-18 13:41:58 +0300 |
commit | f16ae01b12e612701f44c028f188d1ded58d0358 (patch) | |
tree | 4f27231e1e7fdebfa7df9b7c07eb183fa4d82b07 /src/python | |
parent | 6b9882fc142cab4a15a272991096ef4db260bf0f (diff) | |
download | unit-f16ae01b12e612701f44c028f188d1ded58d0358.tar.gz unit-f16ae01b12e612701f44c028f188d1ded58d0358.tar.bz2 |
Python: app module callable name configuration.
Now it is possible to specify the name of the application callable using
optional parameter 'callable'. Default value is 'application'.
This closes #290 issue on GitHub.
Diffstat (limited to 'src/python')
-rw-r--r-- | src/python/nxt_python.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/python/nxt_python.c b/src/python/nxt_python.c index 5b6021bb..7d4589ed 100644 --- a/src/python/nxt_python.c +++ b/src/python/nxt_python.c @@ -60,6 +60,7 @@ nxt_python_start(nxt_task_t *task, nxt_process_data_t *data) char *nxt_py_module; size_t len; PyObject *obj, *pypath, *module; + const char *callable; nxt_unit_ctx_t *unit_ctx; nxt_unit_init_t python_init; nxt_common_app_conf_t *app_conf; @@ -199,16 +200,18 @@ nxt_python_start(nxt_task_t *task, nxt_process_data_t *data) goto fail; } - obj = PyDict_GetItemString(PyModule_GetDict(module), "application"); + callable = (c->callable != NULL) ? c->callable : "application"; + + obj = PyDict_GetItemString(PyModule_GetDict(module), callable); if (nxt_slow_path(obj == NULL)) { - nxt_alert(task, "Python failed to get \"application\" " - "from module \"%s\"", nxt_py_module); + nxt_alert(task, "Python failed to get \"%s\" " + "from module \"%s\"", callable, nxt_py_module); goto fail; } if (nxt_slow_path(PyCallable_Check(obj) == 0)) { - nxt_alert(task, "\"application\" in module \"%s\" " - "is not a callable object", nxt_py_module); + nxt_alert(task, "\"%s\" in module \"%s\" " + "is not a callable object", callable, nxt_py_module); goto fail; } |