skillfed

duet

A simple future-based async library for python.

duet v0.2.9 391.8K downloads/30d#7,010 on PyPI27
Permissive license Apache 2 Active released

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 duet

uv

uv add duet

poetry

poetry add duet

Installing 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

future-based async libraryasync await with futuresgrpc async wrapperre-entrant event loopstructured concurrency pythonfuture wrapping async
async-futuresgrpc-integrationre-entrant

More Application Frameworks packages