8000 gh-91048: Also clear and set ts->asyncio_running_task with eager tasks by ambv · Pull Request #129197 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-91048: Also clear and set ts->asyncio_running_task with eager tasks #129197

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 23, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update _asynciomodule.c
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
  • Loading branch information
ambv and kumaraditya303 authored Jan 23, 2025
commit 6a9f478053d6953396528b4aad754b0c8c20383f
5 changes: 2 additions & 3 deletions Modules/_asynciomodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -2324,7 +2324,6 @@ swap_current_task(asyncio_state *state, PyObject *loop, PyObject *task)
static inline void
set_ts_asyncio_running_task(PyObject *loop, PyObject *task)
{
// This is needed to enable `asyncio.capture_call_graph()` API.
// We want to be enable debuggers and profilers to be able to quickly
// introspect the asyncio running state from another process.
// When we do that, we need to essentially traverse the address space
Expand All @@ -2341,8 +2340,8 @@ set_ts_asyncio_running_task(PyObject *loop, PyObject *task)
// and ever-changing data structure.
//
// So the easier solution is to put a strong reference to the currently
// running `asyncio.Task` on the interpreter thread state (we already
// have some asyncio state there.)
// running `asyncio.Task` on the current thread state (the current loop
// is also stored there.)
_PyThreadStateImpl *ts = (_PyThreadStateImpl *)_PyThreadState_GET();
if (ts->asyncio_running_loop == loop) {
// Protect from a situation when someone calls this method
Expand Down
Loading
0