Uvloop: Inspecting events queued on loop?

Created on 3 Apr 2018  路  2Comments  路  Source: MagicStack/uvloop

  • uvloop version: 0.8.1
  • Python version: 3.6
  • Platform: Linux
  • Can you reproduce the bug with 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.

enhancement

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

All 2 comments

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!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

GoodPete picture GoodPete  路  8Comments

iceboy233 picture iceboy233  路  8Comments

riouh picture riouh  路  9Comments

scottruss picture scottruss  路  4Comments

gaby picture gaby  路  4Comments