Skip to main content

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.9 or later.

Author

Matthias Urlichs <matthias@urlichs.de>

Metadata

Release files for trio-asyncio 0.16.0

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

Source distribution (sdist)

Source distribution for trio-asyncio 0.16.0
File Size Uploaded
trio_asyncio-0.16.0.tar.gz 77.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for trio-asyncio 0.16.0
File Interpreter ABI Platform
trio_asyncio-0.16.0-py3-none-any.whl Python 3 none any Details

Total release size: 117.0 kB

Release files / trio_asyncio-0.16.0.tar.gz

Download URL trio_asyncio-0.16.0.tar.gz
Size 77.1 kB
Tags Source
SHA-256 checksum
How to use checksums
9f4e80aa344555548bf440e0f43072743aac1b3a538ebe3994f52363b7752d6f
BLAKE2b-256 checksum
How to use checksums
e176b6317ad0536e155a9cce6c3f0db9a3b3f63e579e176779712ef3403d4af5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.12.0

Release files / trio_asyncio-0.16.0-py3-none-any.whl

Download URL trio_asyncio-0.16.0-py3-none-any.whl
Size 39.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ab652259e7a3b0293319feea87ac6988b32eb07a49e191bb6cceb361c369deab
BLAKE2b-256 checksum
How to use checksums
7c6bedd95076b498d1d5ed0fdb7cfb42ad7ac80a5d0c2a39161540762ef981e3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.12.0

Release history Release notifications | RSS feed

This release

0.16.0 This release

2 release files

0.15.0

2 release files

0.14.1

2 release files

0.11.0

2 release files

0.10.0

1 release file

0.9.1

1 release file

0.8.4

1 release file

0.8.3

1 release file

0.8.2

1 release file

0.8.1

1 release file

0.8.0

1 release file

0.7.5

1 release file

0.7.0

1 release file

0.5.0

1 release file

0.4.6

1 release file

0.3

1 release file

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