summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrew Clayton <a.clayton@nginx.com>2023-02-07 13:11:10 +0000
committerAndrew Clayton <a.clayton@nginx.com>2023-02-07 14:59:34 +0000
commitcbc01907fef6a028f02d9051b909def920c49f24 (patch)
treea00edcc1ca24fa53e2b2e8c07391ee32ede6cad9
parent9c0a4a09978e0defbc6656c7866a7ca147236733 (diff)
downloadunit-cbc01907fef6a028f02d9051b909def920c49f24.tar.gz
unit-cbc01907fef6a028f02d9051b909def920c49f24.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>
-rw-r--r--src/python/nxt_python_asgi.c7
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;
}