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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file asyncio_inspector-0.1.0.tar.gz.

File metadata

  • Download URL: asyncio_inspector-0.1.0.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for asyncio_inspector-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e2aa1120ba883326b8920ba50295a374d5da308b68671c58c8d4e9f665488cfa
MD5 eadb7ca55a166b75229ae0a82b533d9d
BLAKE2b-256 fc37e8f3a380b55b41fea4b109410b6e05754e1174fadd41809c373e97a919a2

See more details on using hashes here.

File details

Details for the file asyncio_inspector-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for asyncio_inspector-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 93130307422cf1fe97a68f50940c3682f2047b02dfa1de72371eddfb2a14de1b
MD5 b50e869e570969811487280bbb376cb2
BLAKE2b-256 10985db0345fee3ce69ec749c7067efbc562e0306a83d158be420d2ecd3ac01a

See more details on using hashes here.

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