duet
A simple future-based async library for python.
What it is and what it does
Duet is a minimal async library designed to bridge the gap between Future-based APIs (like gRPC) and Python's async/await syntax. Rather than implementing its own event loop, it wraps standard Future objects in awaitable wrappers so you can use them in async functions. The library takes inspiration from structured concurrency but differs in two key ways: it focuses on Future integration rather than full async I/O, and it allows re-entrant event loops—meaning you can call duet.run() from within code that's already running inside duet.run(), which most async libraries forbid. This re-entrancy can simplify gradual refactoring of codebases to async without requiring a complete separation of sync and async code upfront.
Duet depends only on typing-extensions and installs as a pure Python wheel, keeping overhead minimal. It's actively maintained but with infrequent releases; the last update was over a year ago. The library is not an official Google project, though it lives in the Google GitHub organization.
Use it for:
- Wrapping gRPC or other RPC library futures to use them in async/await code without rewriting the underlying API.
- Gradually refactoring synchronous code to async by allowing re-entrant duet.run() calls during the transition.
- Building async wrappers around legacy libraries that return futures but lack native async support.
- Combining Future-based parallelism with structured concurrency patterns in a lightweight package.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Duet is a lightweight async library that wraps Future objects to enable async/await syntax around APIs that return futures, such as gRPC, while supporting re-entrant event loops.
Yes, if you need to integrate Future-based APIs (especially gRPC) into async code or are refactoring a codebase incrementally. The low install friction, permissive license, and re-entrancy feature make it a pragmatic choice for that niche. No known vulnerabilities. Not recommended as a general-purpose async framework.
Install
duet on PyPI
pip
pip install duetuv
uv add duetpoetry
poetry add duetInstalling duet
Before you install
Low friction: pure Python wheel with a single runtime dependency (typing-extensions). Actively maintained with recent commits, though releases are infrequent—last update was over a year ago.
License in practice
Apache 2 permissive license allows commercial and private use with minimal restrictions, making it suitable for most projects.
Quickstart
pip install duet
import duet
from concurrent.futures import Future
async def example():
future = Future()
result = await duet.AwaitableFuture(future)
return result
duet.run(example)
Requires Python 3.9.0 or later.
Verify before relying
- Whether re-entrancy works reliably with all async patterns or has edge cases not documented in the excerpt.
- Performance characteristics compared to asyncio or trio for typical workloads.
- Maturity and stability guarantees given the small repository (27 stars) and infrequent releases.
Package facts
| License | Apache 2 (permissive) |
| Python support | supports the current Python release (>=3.9.0) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — typing-extensions |
| Maintenance | actively maintained — 1,115 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 391,821/month — #7,010 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: duet-0.2.9-py3-none-any.whl
Tags
More Application Frameworks packages
FastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
textualTextual is a Python framework for building…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
mcpBuild and connect to Model Context Protocol…
permissive · top 1,000 on PyPI
WerkzeugWerkzeug is a WSGI utility library providing…
permissive · top 1,000 on PyPI
asyncguiAsyncGui provides structured concurrency…
permissive · top 15,000 on PyPI
synchronicityWraps async functions, generators, and classes…
permissive · top 1,000 on PyPI
greenbackAllows you to call async functions from…
permissive · top 5,000 on PyPI
trioTrio is an async I/O library that lets you…
permissive · top 1,000 on PyPI
unsyncDecorator-based library that runs async…
permissive · top 15,000 on PyPI
anyioAnyIO provides a unified asynchronous API that…
permissive · top 100 on PyPI
futuristFuturist provides futures utilities and…
permissive · top 15,000 on PyPI
requests-futuresWraps the requests library to execute HTTP…
permissive · top 5,000 on PyPI
vineVine provides a Python implementation of…
permissive · top 1,000 on PyPI
threadloopRuns Tornado coroutines from synchronous Python…
permissive · top 15,000 on PyPI