| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Fix ``python -m asyncio ps`` and ``pstree`` showing tasks from only one | ||
| interpreter. Patch by Timofei Ivankov. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -958,33 +958,47 @@ _remote_debugging_RemoteUnwinder_get_all_awaited_by_impl(RemoteUnwinderObject *s | |
| if (ensure_async_debug_offsets(self) < 0) { | ||
| return NULL; | ||
| } | ||
| if (refresh_generation_caches_for_interpreter(self, self->interpreter_addr) < 0) { | ||
| return NULL; | ||
| } | ||
|
|
||
| PyObject *result = PyList_New(0); | ||
| if (result == NULL) { | ||
| set_exception_cause(self, PyExc_MemoryError, "Failed to create awaited_by result list"); | ||
| goto result_err; | ||
| } | ||
|
|
||
| // Process all threads | ||
| if (iterate_threads(self, process_thread_for_awaited_by, result) < 0) { | ||
| goto result_err; | ||
| } | ||
| // gh-158880: Tasks live in every interpreter, not only the one at the list head | ||
| uintptr_t interp = self->interpreter_addr; | ||
| while (interp != 0) { | ||
| if (refresh_generation_caches_for_interpreter(self, interp) < 0) { | ||
| goto result_err; | ||
| } | ||
|
|
||
| uintptr_t head_addr = self->interpreter_addr | ||
| + (uintptr_t)self->async_debug_offsets.asyncio_interpreter_state.asyncio_tasks_head; | ||
| // Process all threads | ||
| if (iterate_threads(self, interp, process_thread_for_awaited_by, result) < 0) { | ||
| goto result_err; | ||
| } | ||
|
|
||
| // On top of a per-thread task lists used by default by asyncio to avoid | ||
| // contention, there is also a fallback per-interpreter list of tasks; | ||
| // any tasks still pending when a thread is destroyed will be moved to the | ||
| // per-interpreter task list. It's unlikely we'll find anything here, but | ||
| // interesting for debugging. | ||
| if (append_awaited_by(self, 0, head_addr, result)) | ||
| { | ||
| set_exception_cause(self, PyExc_RuntimeError, "Failed to append interpreter awaited_by in get_all_awaited_by"); | ||
| goto result_err; | ||
| uintptr_t head_addr = interp | ||
| + (uintptr_t)self->async_debug_offsets.asyncio_interpreter_state.asyncio_tasks_head; | ||
|
|
||
| // On top of a per-thread task lists used by default by asyncio to avoid | ||
| // contention, there is also a fallback per-interpreter list of tasks; | ||
| // any tasks still pending when a thread is destroyed will be moved to | ||
| // the per-interpreter task list. It's unlikely we'll find anything | ||
| // here, but interesting for debugging. | ||
| if (append_awaited_by(self, 0, head_addr, result)) | ||
| { | ||
| set_exception_cause(self, PyExc_RuntimeError, "Failed to append interpreter awaited_by in get_all_awaited_by"); | ||
| goto result_err; | ||
| } | ||
|
|
||
| if (_Py_RemoteDebug_PagedReadRemoteMemory( | ||
| &self->handle, | ||
| interp + (uintptr_t)self->debug_offsets.interpreter_state.next, | ||
| sizeof(void*), | ||
| &interp) < 0) { | ||
| set_exception_cause(self, PyExc_RuntimeError, "Failed to read next interpreter address"); | ||
| goto result_err; | ||
| } | ||
| } | ||
|
|
||
| _Py_RemoteDebug_ClearCache(&self->handle); | ||
| Expand Down Expand Up | @@ -1064,7 +1078,8 @@ _remote_debugging_RemoteUnwinder_get_async_stack_trace_impl(RemoteUnwinderObject | |
| } | ||
|
|
||
| // Process all threads | ||
| if (iterate_threads(self, process_thread_for_async_stack_trace, result) < 0) { | ||
| if (iterate_threads(self, self->interpreter_addr, | ||
|
Comment thread
Copy link
Copy Markdown
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityUnless I'm missing something, get_async_stack_trace() still has the same problem. Maybe it should be a follow-up, though.
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityYeah, it has the problem, i planned to open a separate issue for this to avoid "big-bang" pr
Sorry, something went wrong.
maurycy reacted with thumbs up emoji
All reactions
|
||
| process_thread_for_async_stack_trace, result) < 0) { | ||
| goto result_err; | ||
| } | ||
|
|
||
| Expand Down | ||
| Back | FazBrowse Home | New Git URL |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityOne way to silence https://github.com/python/cpython/actions/runs/37499870518/job/112393935495#step:6:1023 is by wrapping this in except TRANSIENT_ERRORS:
Perhaps a better approach, similar to #158801
cpython/Lib/test/test_external_inspection.py
Lines 2440 to 2460 in 0e75a05
cpython/Lib/test/test_external_inspection.py
Lines 2469 to 2482 in 0e75a05
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityI thought about how to stop the test flaking, so I decided to use queues in the test rather than silence exceptions. I ran the tests overnight many times, and there were no failures, ci here passed too
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.