Registry / http-networking / txaio
library26.6.1pypypi✓ verified 25d ago

txaio provides a compatibility API between Python's asyncio and Twisted frameworks, allowing developers to write backend-agnostic asynchronous code. It is currently at version 25.12.2 and sees active development with regular releases, often preceded by nightly builds.

pip install txaio
INSTALL
IMPORT
SIG · TXAIO
T
txaio
http-networkingpythonv26.6.1
Install
1.6s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v25.9.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 18MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.6s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

txaio
import txaio
use_asyncio
import txaio txaio.use_asyncio()
from txaio import use_asyncio; use_asyncio()
The backend selection (`use_asyncio` or `use_twisted`) should be called once, typically at application startup, using `txaio.<backend_selector>()` after `import txaio`.
with_config
from txaio import with_config
make_logger
from txaio import make_logger
start_logging
from txaio import start_logging

This quickstart demonstrates how to initialize `txaio` with the `asyncio` backend, set up logging, and define a simple asynchronous function using the `@txaio.with_config` decorator to make it backend-agnostic. The function then uses `txaio.sleep` and a `txaio` logger, and is run using `asyncio.run()`.

import txaio import asyncio # 1. Initialize txaio with the desired backend (must be called once at application startup) txaio.use_asyncio() # 2. Start txaio's logging system (optional, but good practice) txaio.start_logging(level='info') log = txaio.make_logger() # 3. Define a backend-agnostic asynchronous function @txaio.with_config async def my_async_function(name: str): log.info(f"Hello from {name} using the {txaio.native_framework_name()} backend!") await txaio.sleep(0.1) log.info(f"Goodbye from {name}.") return f"Completed {name}" # 4. Run the function using the native event loop async def main(): result = await my_async_function("txaio_example") print(f"Function returned: {result}") if __name__ == "__main__": # This uses asyncio.run() since we configured txaio for asyncio asyncio.run(main())
Debug
Known issues
gotchaThe backend must be selected exactly once at application startup using either `txaio.use_asyncio()` or `txaio.use_twisted()`. Calling it multiple times, or calling it late after other txaio operations, can lead to unexpected behavior or errors.
fix
Ensure `txaio.use_asyncio()` or `txaio.use_twisted()` is the first `txaio` function called in your application's entry point.
affects: All versions
breakingIn `v22.1.1`, the functions `txaio.create_future` and `txaio.is_future` were renamed to `txaio.create_defer` and `txaio.is_defer` respectively, specifically when `txaio.use_twisted()` is in effect. Code written for older versions targeting Twisted will break.
fix
Update calls to `txaio.create_future` to `txaio.create_defer` and `txaio.is_future` to `txaio.is_defer` when working with the Twisted backend.
affects: >=22.1.1
gotchatxaio provides a compatibility layer for *one* selected backend at a time (either asyncio or Twisted). It is not designed to seamlessly interoperate between both backends within the same application scope simultaneously. All `txaio` operations will adapt to the single selected backend.
fix
Decide on a single backend (asyncio or Twisted) for your `txaio`-managed code and initialize `txaio` accordingly. Avoid attempts to dynamically switch or mix `txaio` backends within the same runtime context.
affects: All versions
Upgrade
Version history
26.6.1latest on PyPI · released Jun 18, 2026
Audit
Dependencies
TwistedoptionalRequired if using the Twisted backend via `txaio.use_twisted()`.
Agent activity
15 hits · last 30 days
node
10
OpenAI (training)
1
Resources
txaio — pip install txaio · libregistry