PYTHONASYNCIODEBUG in env?: N/A
We're using uvloop in Tornado, and believe we may have an issue with too many pending tasks. Is it possible to monitor the number of tasks scheduled on uvloop and/or extract timing data for the tasks?
Further details: We discovered during a database slowdown that requests to unrelated parts of our application saw significantly increased latency (p50 approaching p99), which seems to indicate our async tasks were spending more of their time waiting to be scheduled rather than running. We'd like to validate this idea by recording any potential backup of tasks to be performed.
uvloop.Loop has a member _queued_streams which could be the sort of data we're looking for, but since that's in the Cython code we can't access it from Python.
You can use asyncio.Task.all_tasks() API to get a number of all asyncio tasks for a particular event loop.
You can also build a debug build of uvloop that exposes a Loop.print_debug_info() method.
I'm also looking into adding deeper introspection/tracing APIs to the next uvloop release. cc/ @pfreixes
This issue is superseded with this https://github.com/MagicStack/uvloop/issues/163, feel free to join the discussion!
Most helpful comment
You can use
asyncio.Task.all_tasks()API to get a number of all asyncio tasks for a particular event loop.You can also build a debug build of uvloop that exposes a
Loop.print_debug_info()method.I'm also looking into adding deeper introspection/tracing APIs to the next uvloop release. cc/ @pfreixes