As you may recall, I have strong feelings about the design of usable APIs for asynchronous libraries.
So, I wrote my own.
I'm happy to announce the first release of Trio, a new permissively-licensed async library for Python:
- Repository: https://github.com/python-trio/trio
- Tutorial + manual: https://trio.readthedocs.io
- Download: https://pypi.python.org/pypi/trio (or just pip install -U trio)
Trio is very much inspired by my work with and on Curio, so much credit to Dave Beazley. They don't share any actual code, and at this point there are many small and large divergences all over the stack, but if you're curious the tipping point where I decided I wanted to explore an incompatible approach was here.
Some noteworthy features:
- Aspires to become production-quality
- Full support for Windows, Linux, MacOS
- Full support for both CPython 3.5+ and for PyPy 3.5 pre-releases
- Flow control is fully async/await-native and easy to reason about: no callbacks, no futures, no implicit concurrency
- Powerful and composable framework for handling cancellation and timeouts
- Strong user-centered guarantees around cancel and schedule points make it easier to manage and reason about cooperative concurrency
- Erlang-influenced interface for task spawning provides a structured system for managing child tasks. If user code raises an exception then it's always propagated until handled, never logged-and-discarded.
- First-class support for introspection and debugging (example)
- Powerful built-in testing helpers. For
example, you can speed up tests that involve timeouts by using a
clock that automatically skips over boring periods
- As a demonstration of the power of good testing tools, trio's own test suite achieves >98% coverage and runs in ~5 seconds in "slow" mode (~2 seconds in default mode).
- Interrupting programs with control-C magically just works.
- A mostly-written tutorial that doesn't assume any familiarity with async/await.
- A low-level "hazmat" API for when you need to go under the hood. To make sure it's powerful enough, Trio's main synchronization, networking, and threading APIs are implemented using only public interfaces.
- Exposes a whole laundry list of Python limitations.
- Lots of missing pieces left for you to help fill in! :-)
I hope you'll check it out!