Skip to main content

Trace python asyncio tasks exceptions live

Project description

Python application Pypi version Downloads codecov

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


Download files

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

Source Distribution

aio_live_task_traces-0.0.2.tar.gz (40.1 kB view hashes)

Uploaded Source

Built Distribution

aio_live_task_traces-0.0.2-py2.py3-none-any.whl (28.7 kB view hashes)

Uploaded Python 2 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