Skip to main content

Awesome asyncio_inspector created by pappacena

Project description


asyncio_inspector

codecov CI

Crazily simple statistics tracker for asyncio event loops, for the moments when just setting the event loop to debug mode is not enough.

This package is meant to be used to track basic statistics about asyncio event loops, so you can easily see which methods are blocking the event loop for longer, preventing other tasks from running.

Install it from PyPI

pip install asyncio_inspector

Usage

Enable inspection on any given event loop with the inspect(event_loop) and uninspect(event_loop) methods:

from asyncio_inspector import inspect, uninspect

loop = asyncio.get_event_loop()
stats_tracker = inspect(loop)
loop.call_soon(my_async_function)
loop.call_soon(another_async_function)
loop.call_soon(loop.stop)

uninspect(loop)

Or with a context manager:

loop = asyncio.get_event_loop()
with enable_inpection(loop) as stats_tracker:
    await my_async_function()
    await another_async_function()

Then, you will have some statistics in the stats_tracker object:

stats_tracker.call_counts == {
    "my_async_function": 1,
    "another_async_function": 1
}

# Times are in nanosecs
stats_tracker.total_time == {
    "my_async_function": 123,
    "another_async_function": 333
}

stats_tracker.max_time == {
    "my_async_function": 400,
    "another_async_function": 500
}

stats_tracker.min_time == {
    "my_async_function": 100,
    "another_async_function": 200
}

Development

Read the CONTRIBUTING.md file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

asyncio_inspector-0.1.0.tar.gz (6.5 kB view hashes)

Uploaded Source

Built Distribution

asyncio_inspector-0.1.0-py3-none-any.whl (6.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page