tricycle

Miscellaneous extensions for Trio, the friendly async I/O library


Keywords
async, trio
Licenses
MIT/Apache-2.0
Install
pip install tricycle==0.4.1

Documentation

tricycle: miscellaneous extensions for Trio

Latest PyPI version Automated test status Documentation status Test coverage Code style: black Checked with mypy

This is a library of extensions to Trio, the friendly Python library for async concurrency and I/O.

Currently we have:

  • a readers-writer lock (tricycle.RWLock)
  • slightly higher-level stream wrappers (tricycle.BufferedReceiveStream and tricycle.TextReceiveStream)
  • some tools for managing cancellation (tricycle.open_service_nursery() and tricycle.MultiCancelScope)
  • a way to make objects that want to keep background tasks running during the object's lifetime (tricycle.BackgroundObject and the more general tricycle.ScopedObject)
  • an analog of ContextVar that is inherited through the task tree rather than across start_soon() calls, and thus provides more safety for accessing a resource that is being managed by a parent task (tricycle.TreeVar)

While we won't release known-broken code, and we strive for cleanliness and good test coverage, please be advised that tricycle is mostly one person's box of tools and has not necessarily been reviewed or tested to Trio's standards. It is being used in production, and API churn has been minimal thus far although we're not making any firm stability guarantees. If you find that it doesn't meet your needs, feel free to let us know and we'll endeavor to improve things.

tricycle is tested on Linux, Windows, and macOS, on CPython versions 3.8 through 3.12. It will probably work on PyPy as well.

License and history

tricycle is licensed under your choice of the MIT or Apache 2.0 license. See LICENSE for details.

This library has its origins in a package of utilities that the author wrote at Hudson River Trading while building things for them with Trio. Many thanks to HRT for supporting open source in this way!