Skip to content

Commit

Permalink
gh-121621: clear running loop early in asyncio (#128004)
Browse files Browse the repository at this point in the history
  • Loading branch information
kumaraditya303 authored Dec 18, 2024
1 parent dbd08fb commit 8a433b6
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Modules/_asynciomodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -3723,6 +3723,11 @@ module_clear(PyObject *mod)
Py_CLEAR(state->iscoroutine_typecache);

Py_CLEAR(state->context_kwname);
// Clear the ref to running loop so that finalizers can run early.
// If there are other running loops in different threads,
// those get cleared in PyThreadState_Clear.
_PyThreadStateImpl *ts = (_PyThreadStateImpl *)_PyThreadState_GET();
Py_CLEAR(ts->asyncio_running_loop);

return 0;
}
Expand Down

0 comments on commit 8a433b6

Please sign in to comment.