Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

asynctb is a library that helps you get tracebacks of parts of your running Python program. It was originally designed with async tasks in mind (thus the name), but also has some support for threads, greenlets, and ordinary synchronous code. It is loosely affiliated with the Trio async framework, and shares Trio’s obsessive focus on usability and correctness. You don’t have to use it with Trio, though; its only package dependency is attrs.

This is mostly intended as a building block for other debugging and introspection tools. You can use it directly, but there’s only rudimentary support for end-user-facing niceties such as pretty-printed output. On the other hand, the core logic is extremely flexible:

  • Tracebacks can be extracted for generators (regular and async), coroutine objects, greenlets, threads, and ranges of frame objects.

  • Other awaitables can be handled by defining an “unwrapper”, which takes an awaitable of that type and returns a coroutine or generator. Several are supported out of the box, for async generator asend() and athrow() methods and coroutine_wrapper objects. Third-party packages can add more.

  • Tracebacks can include information about what context managers are active in each frame, including references to the context manager objects themselves. For example, this can be used to draw a detailed Trio task tree. The logic knows how to look inside @contextmanager, ExitStack, and their async equivalents (both those in the stdlib and their popular backports in async_generator and async_exit_stack). Third-party packages can define context manager unwrappers too.

  • There are a number of customization points allowing third-party packages to specify that some of their functions and/or those functions’ callees should be excluded from asynctb tracebacks, or should incorporate the traceback of another object that asynctb knows how to handle. For example, the traceback of a Trio task blocked in trio.to_thread.run_sync() could cover the code that’s running in the thread as well.

And of course, if you want to disable all of this and just have a version of inspect.stack() that takes a coroutine object, you can.

asynctb requires Python 3.6 or later. It is tested with CPython (every minor version through 3.10-dev) and PyPy, on Linux, Windows, and macOS. It will probably work on other operating systems. Basic features will work on other interpreters, but the context manager decoding will be less intelligent, and won’t work at all without a usable gc.get_referents().

This is still in development. It has full test coverage, but will likely undergo some incompatible API changes before an initial release. Documentation is also currently light. Watch this space!

License: Your choice of MIT or Apache License 2.0

Release files for asynctb 0.0.0a0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for asynctb 0.0.0a0
File Size Uploaded
asynctb-0.0.0a0.tar.gz 53.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for asynctb 0.0.0a0
File Interpreter ABI Platform
asynctb-0.0.0a0-py3-none-any.whl Python 3 none any Details

Total release size: 106.1 kB

Release files / asynctb-0.0.0a0.tar.gz

Download URL asynctb-0.0.0a0.tar.gz
Size 53.4 kB
Tags Source
SHA-256 checksum
How to use checksums
93a43c5c47447a34287da6d99e20e93f166e189c845106b2c07ac6d33837e47d
BLAKE2b-256 checksum
How to use checksums
21ed7b1108b4a77c83feaf988b850e57c1f4a3f69da3530a090a9913e4ecccee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.10.4

Release files / asynctb-0.0.0a0-py3-none-any.whl

Download URL asynctb-0.0.0a0-py3-none-any.whl
Size 52.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f7f75f263a721c1c3d64160d93b0f06fd0f6f7399ab4c54dc745c23ecfb1c8dc
BLAKE2b-256 checksum
How to use checksums
d50623c506108d9b1674de83426c18dd87903fda506f8261b0396f458d7066d9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.10.4

Release history Release notifications | RSS feed

This release

0.0.0a0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page