skillfed

txaio

Compatibility API between asyncio/Twisted/Trollius

txaio v26.6.1 6.8M downloads/30d#1,842 on PyPI56
Permissive license MIT Active released

What it is and what it does

txaio is an abstraction layer over async event loops, similar to how six bridges Python 2 and 3 differences. Instead of writing separate code paths for Twisted's Deferred and asyncio's Future, you write against txaio's unified API and choose at runtime which event loop to use. Your code runs natively on whichever framework you select—there is no event loop adapter or bridge, just a compatibility shim over the core abstractions like futures, callbacks, and errbacks.

The library is useful when you want to write a library or application that doesn't force a dependency choice on users. You provide helper functions like `create_future()`, `add_callbacks()`, `resolve()`, and `reject()` that map to the underlying framework's primitives. This means a single codebase can serve both Twisted and asyncio users without modification, though it does require you to adopt txaio's function-based style rather than direct object instantiation.

Use it for:

  • Write a library that works with both Twisted and asyncio without maintaining two code paths.
  • Build an application where users can choose their async framework at deployment time without code changes.
  • Migrate from Twisted to asyncio (or vice versa) incrementally by using txaio as a compatibility bridge.
  • Create async utilities and helpers that are framework-agnostic and reusable across projects.
  • Test the same async logic against both event loops to ensure portability.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

txaio provides a compatibility layer that lets you write async code once and run it unmodified on either Twisted or asyncio, letting your users choose which event loop to use.

Yes. txaio is actively maintained, has no dependencies, installs easily, carries no security vulnerabilities, and solves a real problem for anyone writing async code that needs to support multiple event loop frameworks. Use it if you're building a library or application that should work with both Twisted and asyncio; skip it if you're committed to a single framework.

Install

txaio on PyPI

pip

pip install txaio

uv

uv add txaio

poetry

poetry add txaio

Installing txaio

Before you install

Low friction—pure Python wheel with no runtime dependencies. Actively maintained with a recent release; last commit 2026-06-18.

License in practice

MIT license (permissive); you can use, modify, and distribute this package with minimal restrictions.

Quickstart

pip install txaio

import txaio
txaio.use_twisted()  # or .use_asyncio()

f = txaio.create_future()
txaio.resolve(f, "value")
result = txaio.as_future(some_func, 1, 2)

Requires Python 3.11 or later; you must have either Twisted or asyncio available at runtime.

Verify before relying

  • Whether Trollius support is still actively tested or documented given the description mentions it but the classifiers do not.
  • Current test coverage across CPython 3.11+ and PyPy 3 versions listed in classifiers.

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.11)
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance actively maintained — 57 days since the last release
Last repo commit
First released
Downloads 6,822,988/month — #1,842 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: txaio-26.6.1-py3-none-any.whl

Keywords: asyncio, coroutine, trollius, twisted

Development Status :: 5 - Production/StableEnvironment :: ConsoleFramework :: TwistedIntended Audience :: DevelopersOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Software Development :: LibrariesTopic :: Software Development :: Libraries :: Application Frameworks

Tags

twisted asyncio compatibilitywrite once run on both event loopsasyncio twisted abstractionevent loop agnostic codesource code compatibility twisted asynciodeferred future wrappercross-framework async
async-abstractionevent-loop-agnostictwisted-asyncio

More Libraries packages