Bug report
python -m asyncio ps shows tasks from only one interpreter, so the main interpreter's tasks disappear once a subinterpreter exists
Repro:
import asyncio, os
from concurrent.futures import InterpreterPoolExecutor
def in_subinterpreter():
import asyncio
async def sub_main():
await asyncio.sleep(10_000)
asyncio.run(sub_main())
async def main():
loop = asyncio.get_running_loop()
loop.run_in_executor(InterpreterPoolExecutor(), in_subinterpreter)
await asyncio.sleep(1)
print(os.getpid(), flush=True)
await asyncio.sleep(10_000)
asyncio.run(main())
Run:
sudo ./python.exe -m asyncio ps <PID>
Actual output:
tid task id task name coroutine stack awaiter chain awaiter name awaiter id
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
20354601 0x1049c94f0 Task-1 sleep -> in_subinterpreter.<locals>.sub_main 0x0
Expected:
tid task id task name coroutine stack awaiter chain awaiter name awaiter id
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
20352316 0x106be14f0 Task-1 sleep -> in_subinterpreter.<locals>.sub_main 0x0
20352315 0x105f64f50 Task-1 sleep -> main 0x0
Proposed fix: add per-interpreter traversal in _remote_debugging_RemoteUnwinder_get_all_awaited_by_impl
I have a fix ready
CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS
Bug report
python -m asyncio psshows tasks from only one interpreter, so the main interpreter's tasks disappear once a subinterpreter existsRepro:
Run:
Actual output:
Expected:
Proposed fix: add per-interpreter traversal in
_remote_debugging_RemoteUnwinder_get_all_awaited_by_implI have a fix ready
CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS