diff options
author | Andrew Clayton <a.clayton@nginx.com> | 2023-02-07 13:11:10 +0000 |
---|---|---|
committer | Andrew Clayton <a.clayton@nginx.com> | 2023-02-07 13:11:10 +0000 |
commit | b2d19155787e7dd85f0a915bb74d4c9aa2cd91d6 (patch) | |
tree | a65bb85285fd19d34b9c5c5fa42a4b3e9e3cf7de /src | |
parent | 843ae1b842a180605f8d5e897d5e7cb128375fc1 (diff) | |
download | unit-b2d19155787e7dd85f0a915bb74d4c9aa2cd91d6.tar.gz unit-b2d19155787e7dd85f0a915bb74d4c9aa2cd91d6.tar.bz2 |
Python: ASGI: Don't log asyncio.get_running_loop() errors.
This adds a check to nxt_python_asgi_get_event_loop() on the
event_loop_func name in the case that running that function fails, and
if it's get_running_loop() that failed we skip printing an error message
as this is an often expected behaviour since the previous commit and we
don't want users reporting erroneous bugs.
This check will always happen regardless of Python version while it
really only applies to Python >= 3.7, there didn't seem much point
adding complexity to the code for this case and in what will be an ever
diminishing case of people running older Pythons.
Reviewed-by: Alejandro Colomar <alx@nginx.com>
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/python/nxt_python_asgi.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/python/nxt_python_asgi.c b/src/python/nxt_python_asgi.c index f26f5a5d..adf03e2b 100644 --- a/src/python/nxt_python_asgi.c +++ b/src/python/nxt_python_asgi.c @@ -224,8 +224,11 @@ nxt_python_asgi_get_event_loop(PyObject *asyncio, const char *event_loop_func) loop = PyObject_CallObject(event_loop, NULL); if (nxt_slow_path(loop == NULL)) { - nxt_unit_alert(NULL, "Python failed to call 'asyncio.%s'", - event_loop_func); + if (strcmp(event_loop_func, "get_running_loop") != 0) { + nxt_unit_alert(NULL, "Python failed to call 'asyncio.%s'", + event_loop_func); + } + return NULL; } |