diff --git a/Modules/_asynciomodule.c b/Modules/_asynciomodule.c index 8763e7592924ba1..0b8a721f9edf820 100644 --- a/Modules/_asynciomodule.c +++ b/Modules/_asynciomodule.c @@ -3768,6 +3768,12 @@ _asyncio_all_tasks_impl(PyObject *module, PyObject *loop) } int err = 0; + // The linked list holds borowed references to the tasks + // so before reading from it, all other threads + // are stopped using stop the world event so that + // no task could be deallocated while being added to the list. + // The state critical section need not to be held as + // all other threads are paused. PyInterpreterState *interp = PyInterpreterState_Get(); _PyEval_StopTheWorld(interp);