Trace python asyncio tasks exceptions live
Project description
aio-live-tasks-exceptions
Trace python asyncio tasks exceptions live!
Installation
Install the last released version using pip
:
python3 -m pip install -U aio-live-task-traces
Or install the latest version from sources:
git clone git@github.com:matan1008/aio-live-task-traces.git
cd aio-live-task-traces
python3 -m pip install -U -e .
Usage
Usually, if you run a task that throws exception using asyncio you will not be aware of the exception until the task is awaited or deleted. For example:
import asyncio
async def faulty_task():
raise Exception('foo')
async def main():
task = asyncio.create_task(faulty_task())
await asyncio.sleep(3600)
await task
if __name__ == '__main__':
# The exception will be printed after 3600 seconds
asyncio.run(main())
This package, will wrap each task you run so the exception will be traced the moment it raises:
import asyncio
from aio_live_task_traces import set_live_task_traces
async def faulty_task():
raise Exception('foo')
async def main():
set_live_task_traces(True)
task = asyncio.create_task(faulty_task())
await asyncio.sleep(3600)
await task
if __name__ == '__main__':
# The exception will be printed both immediately and after 3600 seconds
asyncio.run(main())
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file aio_live_task_traces-0.0.2.tar.gz
.
File metadata
- Download URL: aio_live_task_traces-0.0.2.tar.gz
- Upload date:
- Size: 40.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b115cc6ba190891f517f7e2ed3c24479e744ff50a8c3607907a4058d1c24c315 |
|
MD5 | 69f5a1da68f68ca3349328acf8c31b01 |
|
BLAKE2b-256 | 8be4eeb76d002b9a3d445500b554a4d3951bfd537e9e8e27478e1c4db05713a6 |
File details
Details for the file aio_live_task_traces-0.0.2-py2.py3-none-any.whl
.
File metadata
- Download URL: aio_live_task_traces-0.0.2-py2.py3-none-any.whl
- Upload date:
- Size: 28.7 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5aa1843a6acdbf13bd1907f7e9d73e9d98007650e6c51c65fef7dec96b3a450f |
|
MD5 | aa098f5f12bc8da11b70aa1d18434e7b |
|
BLAKE2b-256 | 1e78d479839fa98f56f0c6a9b0f27a902b7f750bd9f90cce2e884a5e25d83976 |