summaryrefslogtreecommitdiffhomepage
path: root/src/python/nxt_python_asgi.c
diff options
context:
space:
mode:
authorKonstantin Pavlov <thresh@nginx.com>2022-06-02 16:51:49 +0400
committerKonstantin Pavlov <thresh@nginx.com>2022-06-02 16:51:49 +0400
commitd9fddee1dbfc1f5d49c8f40386289d7188030952 (patch)
tree842a62b343ac33eba10e7a426a10b55bb1c46aed /src/python/nxt_python_asgi.c
parent420395ee2e7cd464e157c49bea3d74f15bf25f30 (diff)
parent0d48fe73c4450901622373e35f6ff3a944ec13d6 (diff)
downloadunit-d9fddee1dbfc1f5d49c8f40386289d7188030952.tar.gz
unit-d9fddee1dbfc1f5d49c8f40386289d7188030952.tar.bz2
Merged with the default branch.1.27.0-1
Diffstat (limited to 'src/python/nxt_python_asgi.c')
-rw-r--r--src/python/nxt_python_asgi.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/python/nxt_python_asgi.c b/src/python/nxt_python_asgi.c
index 354e3a81..91af8f4b 100644
--- a/src/python/nxt_python_asgi.c
+++ b/src/python/nxt_python_asgi.c
@@ -117,15 +117,20 @@ nxt_python_asgi_get_func(PyObject *obj)
if (PyMethod_Check(call)) {
obj = PyMethod_GET_FUNCTION(call);
- Py_INCREF(obj);
- Py_DECREF(call);
+ if (PyFunction_Check(obj)) {
+ Py_INCREF(obj);
- return obj;
+ } else {
+ obj = NULL;
+ }
+
+ } else {
+ obj = NULL;
}
Py_DECREF(call);
- return NULL;
+ return obj;
}
@@ -161,8 +166,10 @@ nxt_python_asgi_init(nxt_unit_init_t *init, nxt_python_proto_t *proto)
for (i = 0; i < nxt_py_targets->count; i++) {
func = nxt_python_asgi_get_func(nxt_py_targets->target[i].application);
if (nxt_slow_path(func == NULL)) {
- nxt_unit_alert(NULL, "Python cannot find function for callable");
- return NXT_UNIT_ERROR;
+ nxt_unit_debug(NULL, "asgi: cannot find function for callable, "
+ "unable to check for legacy mode (#%d)",
+ (int) i);
+ continue;
}
code = (PyCodeObject *) PyFunction_GET_CODE(func);