Skip to content

Commit b2d1915

Browse files
committed
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 <[email protected]> Signed-off-by: Andrew Clayton <[email protected]>
1 parent 843ae1b commit b2d1915

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/python/nxt_python_asgi.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,11 @@ nxt_python_asgi_get_event_loop(PyObject *asyncio, const char *event_loop_func)
224224

225225
loop = PyObject_CallObject(event_loop, NULL);
226226
if (nxt_slow_path(loop == NULL)) {
227-
nxt_unit_alert(NULL, "Python failed to call 'asyncio.%s'",
228-
event_loop_func);
227+
if (strcmp(event_loop_func, "get_running_loop") != 0) {
228+
nxt_unit_alert(NULL, "Python failed to call 'asyncio.%s'",
229+
event_loop_func);
230+
}
231+
229232
return NULL;
230233
}
231234

0 commit comments

Comments
 (0)