https://github.com/python/cpython/commit/8a433b683fecafe1cb04469a301df2b4618167d0
commit: 8a433b683fecafe1cb04469a301df2b4618167d0
branch: main
author: Kumar Aditya <[email protected]>
committer: kumaraditya303 <[email protected]>
date: 2024-12-18T14:25:03Z
summary:
gh-121621: clear running loop early in asyncio (#128004)
files:
M Modules/_asynciomodule.c
diff --git a/Modules/_asynciomodule.c b/Modules/_asynciomodule.c
index 13dd2fd55fd454..27c16364457336 100644
--- a/Modules/_asynciomodule.c
+++ b/Modules/_asynciomodule.c
@@ -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;
}
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]