Repository navigation
gh-158880: Fix asyncio ps showing tasks from only one interpreter - #158900
deadlovelll wants to merge 3 commits into
Conversation
| loop.run_in_executor(pool, _asyncio_in_subinterpreter) | ||
| task = asyncio.create_task(main_worker(), name="main_worker") | ||
| self.addCleanup(task.cancel) | ||
| await asyncio.sleep(1) |
There was a problem hiding this comment.
asyncio.sleep feels like a flaky risk. What do you think about using busy_retry instead?
There was a problem hiding this comment.
Thanks! I fixed it
|
|
||
| // Process all threads | ||
| if (iterate_threads(self, process_thread_for_async_stack_trace, result) < 0) { | ||
| if (iterate_threads(self, self->interpreter_addr, |
There was a problem hiding this comment.
Unless I'm missing something, get_async_stack_trace() still has the same problem. Maybe it should be a follow-up, though.
There was a problem hiding this comment.
Yeah, it has the problem, i planned to open a separate issue for this to avoid "big-bang" pr
| return NULL; | ||
| } | ||
| if (refresh_generation_caches_for_interpreter(self, self->interpreter_addr) < 0) { | ||
| PyObject *seen = PySet_New(NULL); |
There was a problem hiding this comment.
This is just a list:
cpython/Modules/_remote_debugging/module.c
Lines 719 to 720 in 9028df3
cpython/Modules/_remote_debugging/module.c
Lines 884 to 885 in 9028df3
cpython/Modules/_remote_debugging/frames.c
Lines 459 to 462 in 182f323
Is there a reproducible race scenario where we'd see a cycle? (It was quiet easy to reproduce issues like ABA.)
There was a problem hiding this comment.
No, I couldn't reproduce a cycle. I thought the interpreter walk could loop
because of the previous PR, that's why I added the set. I agree with your suggestion and will rework it soon
| for info in RemoteUnwinder( | ||
| os.getpid()).get_all_awaited_by() |
There was a problem hiding this comment.
One 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
Fix asyncio ps showing tasks from only one interpreter
For details see gh-158880