Bug report
profiling.sampling --async-aware shows tasks from only one interpreter, so the main interpreter's tasks disappear once a subinterpreter exists
Repro:
import asyncio, os, time
from concurrent.futures import InterpreterPoolExecutor
def blocking_work():
import asyncio, time
async def sub_spin():
deadline = time.monotonic() + 60
while time.monotonic() < deadline:
pass
asyncio.run(sub_spin())
async def main():
loop = asyncio.get_running_loop()
with InterpreterPoolExecutor() as pool:
loop.run_in_executor(pool, blocking_work)
print(os.getpid(), flush=True)
deadline = time.monotonic() + 60
while time.monotonic() < deadline:
pass
asyncio.run(main())
Run:
sudo ./python.exe -m profiling.sampling dump --async-aware --async-mode running <PID>
Actual output:
Stack dump for PID 72163, thread 24398118 (task 4404221168; most recent call last):
File "<task>", in Task-1
File "repro.py", line 9, in blocking_work.<locals>.sub_spin
while time.monotonic() < deadline:
Expected:
Stack dump for PID 72163, thread 24398118 (task 4404221168; most recent call last):
File "<task>", in Task-1
File "repro.py", line 9, in blocking_work.<locals>.sub_spin
while time.monotonic() < deadline:
Stack dump, thread 24398104 (task 4379889488; most recent call last):
File "<task>", in Task-1
File "repro.py", line 20, in main
while time.monotonic() < deadline:
Proposed fix: add subinterpreter traversal like #158900 do
I'll work on the fix
CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS
Linked PRs
Bug report
profiling.sampling --async-awareshows tasks from only one interpreter, so the main interpreter's tasks disappear once a subinterpreter existsRepro:
Run:
Actual output:
Expected:
Proposed fix: add subinterpreter traversal like #158900 do
I'll work on the fix
CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS
Linked PRs