summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/nxt_application.h1
-rw-r--r--src/nxt_conf_validation.c6
-rw-r--r--src/nxt_main_process.c6
-rw-r--r--src/python/nxt_python.c13
4 files changed, 21 insertions, 5 deletions
diff --git a/src/nxt_application.h b/src/nxt_application.h
index 3144dc3f..cb49a033 100644
--- a/src/nxt_application.h
+++ b/src/nxt_application.h
@@ -50,6 +50,7 @@ typedef struct {
char *home;
nxt_str_t path;
nxt_str_t module;
+ char *callable;
} nxt_python_app_conf_t;
diff --git a/src/nxt_conf_validation.c b/src/nxt_conf_validation.c
index 9dd4f715..4364057b 100644
--- a/src/nxt_conf_validation.c
+++ b/src/nxt_conf_validation.c
@@ -773,6 +773,12 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_python_members[] = {
NULL,
NULL },
+ { nxt_string("callable"),
+ NXT_CONF_VLDT_STRING,
+ 0,
+ NULL,
+ NULL },
+
NXT_CONF_VLDT_NEXT(&nxt_conf_vldt_common_members)
};
diff --git a/src/nxt_main_process.c b/src/nxt_main_process.c
index 544a0cbd..d2edab1d 100644
--- a/src/nxt_main_process.c
+++ b/src/nxt_main_process.c
@@ -191,6 +191,12 @@ static nxt_conf_map_t nxt_python_app_conf[] = {
NXT_CONF_MAP_STR,
offsetof(nxt_common_app_conf_t, u.python.module),
},
+
+ {
+ nxt_string("callable"),
+ NXT_CONF_MAP_CSTRZ,
+ offsetof(nxt_common_app_conf_t, u.python.callable),
+ },
};
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;
}