A re-implementation of the asyncio mainloop on top of Trio
Project description
trio-asyncio is a re-implementation of the asyncio mainloop on top of Trio.
Rationale
There are quite a few asyncio-compatible libraries.
On the other hand, Trio has native concepts of tasks and task cancellation. Asyncio, on the other hand, is based on chaining Future objects, albeit with nicer syntax.
Thus, being able to use asyncio libraries from Trio is useful.
Principle of operation
The core of the “normal” asyncio main loop is the repeated execution of synchronous code that’s submitted to call_soon or add_reader/add_writer.
Everything else within asyncio, i.e. Futures and async/await, is just syntactic sugar. There is no concept of a task; while a Future can be cancelled, that in itself doesn’t affect the code responsible for fulfilling it.
On the other hand, trio has genuine tasks with no separation between returning a value asynchronously, and the code responsible for providing that value.
trio_asyncio implements a task which runs (its own version of) the asyncio main loop. It also contains shim code which translates between these concepts as transparently and correctly as possible, and it supplants a few of the standard loop’s key functions.
This works rather well: trio_asyncio consists of just ~700 lines of code (asyncio: ~8000) but passes the complete Python 3.6 test suite with no errors.
trio_asyncio requires Python 3.5.3 or better.
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
File details
Details for the file trio_asyncio-0.8.3.tar.gz
.
File metadata
- Download URL: trio_asyncio-0.8.3.tar.gz
- Upload date:
- Size: 120.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: Python-urllib/3.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bcb0c3a4d48f59f01702cbcebfb8027c3482683b8881725f93ed529293299e06 |
|
MD5 | 37f045cb36910b0f8a1123bd309d6504 |
|
BLAKE2b-256 | 6b52586adce1321641fac316ebfaaec3daccde14f5f54198f6a8f1175e7e0a26 |