Skip to main content

A tiny library for monitoring and testing asyncio programs

Project description

This is a tiny library for monitoring and testing asyncio programs. Its monitoring features are meant to be always on in production.

Aiodebug will use logwood if it is installed, otherwise it will default to the standard logging module.

Aiodebug is only tested with Python 3.5. There are no plans to support older versions.

Log warnings when callbacks block the event loop

aiodebug.log_slow_callbacks.enable(0.05)

This will produce WARNING-level logs such as

Executing <Task pending coro=<foo() running at /home/.../foo.py:37>
wait_for=<Future pending cb=[Task._wakeup()]>> took 0.069 seconds

Asyncio already does this in debug mode, but you probably don’t want to enable full-on debug mode in production.

Track event loop lags in StatsD

aiodebug.monitor_loop_lag.enable(statsd_client)

Tracks how much scheduled calls get delayed and sends the lags to StatsD:

https://github.com/qntln/aiodebug/raw/master/docs/loop-lags.png

Speed up or slow down time in the event loop

This is mainly useful for testing.

loop = aiodebug.testing.time_dilated_loop.TimeDilatedLoop()
asyncio.set_event_loop(loop)

loop.time_dilation = 3
await asyncio.sleep(1) # Takes 0.333s of real time

loop.time_dilation = 0.1
await asyncio.sleep(1) # Takes 10s of real time

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

aiodebug-1.1.2.tar.gz (4.0 kB view details)

Uploaded Source

File details

Details for the file aiodebug-1.1.2.tar.gz.

File metadata

  • Download URL: aiodebug-1.1.2.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for aiodebug-1.1.2.tar.gz
Algorithm Hash digest
SHA256 061dd0067f80a433a1e4fa4f76dd1b4cf366ee0ce2035e462ba3af00c79241ea
MD5 8cf8ea1e051e79330b959ed0a6ca33df
BLAKE2b-256 36b706aa0e122ddc7c98713e41da9a13c93acd8e040539803d1f065d670e32c8

See more details on using hashes here.

Provenance

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