greenback
Reenter an async event loop from synchronous code
Decision gist · record as of 2026-08-14
Yes, if you need to migrate existing sync code to async incrementally or interoperate with non-async libraries without threading. The library is actively maintained, has no known vulnerabilities, low install friction, and is permissively licensed. The main trade-off is a small performance cost per task and the requirement that C extensions used alongside greenback must be well-behaved. For greenfield async projects, it's unnecessary; for bridging sync and async, it's a solid choice.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.8+.
- Greenlet must be available; works on CPython and PyPy but not other implementations.
- Poorly-behaved C extensions may crash when used with greenback.
License · maintenance · safety
MIT -or- Apache License 2.0 (permissive) — Dual-licensed under MIT or Apache 2.0 (permissive). You may choose either license for your use, giving flexibility for both proprietary and open-source projects.
last release 2025-12-23 (234 days) · last repo commit 2026-02-17 · 92 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 9,609,038 downloads/mo, #1,520 on PyPI
Alternatives
Verify before relying
import greenback
async def main():
await greenback.ensure_portal()
result = greenback.await_(some_async_function())
await main()- Whether the minor performance impact of running tasks inside a greenlet is acceptable for your specific workload.
- Compatibility with C extension modules in your dependency tree—greenback may expose latent bugs in extensions that violate greenlet's assumptions about heap allocation.
- Whether greenback.await_() works reliably with all async frameworks beyond asyncio and Trio.
What it is and what it does
Greenback solves the problem of incrementally migrating a synchronous codebase to async/await syntax. When you port code to asyncio or Trio, you typically must convert every function in the call chain to async, even if most of them don't perform I/O themselves. Greenback lets you call async functions from synchronous code, as long as that sync code was originally invoked from an async task that set up a greenback portal.
It works by running your async task inside a greenlet, then using greenlet's context-switching to jump back to the parent greenlet (which has direct access to the event loop) when you call greenback.await_(). The result or exception from the async call is then returned to the task greenlet. The library is pure Python on top of the mature greenlet C module, with minimal overhead.
Use it for
- Incrementally port a large codebase to async/await one layer at a time, leaving middle-layer functions unchanged.
- Interoperate with existing libraries that don't support async without spawning threads or rewriting their internals.
- Design async APIs that need to block in places where await syntax is forbidden, such as property getters.
- Call async functions from synchronous wrapper functions in a legacy codebase without full conversion.
- Bridge between synchronous and asynchronous code paths within the same event loop task.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you need to migrate existing sync code to async incrementally or interoperate with non-async libraries without threading.
The library is actively maintained, has no known vulnerabilities, low install friction, and is permissively licensed. The main trade-off is a small performance cost per task and the requirement that C extensions used alongside greenback must be well-behaved. For greenfield async projects, it's unnecessary; for bridging sync and async, it's a solid choice.
Install
greenback on PyPI
Before you install
Low friction: pure Python wheel with only three runtime dependencies (greenlet, sniffio, outcome). Actively maintained as of 2026-02-17 with 92 repository stars. Requires Python 3.8 or later and greenlet support (CPython and PyPy both work).
Requires Python 3.8+. Greenlet must be available; works on CPython and PyPy but not other implementations. Poorly-behaved C extensions may crash when used with greenback.
License in practice
Dual-licensed under MIT or Apache 2.0 (permissive). You may choose either license for your use, giving flexibility for both proprietary and open-source projects.
Quickstart
import greenback
async def main():
await greenback.ensure_portal()
result = greenback.await_(some_async_function())
await main()
Verify before relying
- Whether the minor performance impact of running tasks inside a greenlet is acceptable for your specific workload.
- Compatibility with C extension modules in your dependency tree—greenback may expose latent bugs in extensions that violate greenlet's assumptions about heap allocation.
- Whether greenback.await_() works reliably with all async frameworks beyond asyncio and Trio.
Package facts
| License | MIT -or- Apache License 2.0 permissive |
| Python support | Supports the current Python release >=3.8 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 3 packagesgreenletsniffiooutcome |
| Maintenance | Actively maintained 234 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 9,609,038 / month, #1,520 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 4 - BetaFramework :: AsyncIOFramework :: TrioLicense :: OSI Approved :: Apache Software LicenseLicense :: OSI Approved :: MIT LicenseOperating System :: MacOS :: MacOS XOperating System :: Microsoft :: WindowsOperating System :: POSIX :: LinuxProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPy |
Evidence: greenback-1.3.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “call async from sync code”
- greenbackAllows you to call async functions from synchronous code that runs…
- asyncerAsyncer provides utility functions for working with async/await code…
- syncerSyncer converts async functions to synchronous callables, allowing…
Give your agent the search over MCP, or paste the wish link into any chat.
More Application Frameworks packages
FastAPI is a Python web framework for building REST APIs using type hints, with automatic request validation, serialization, and interactive API documentation.
Provides a way to document function parameters, class attributes, return types, and variables inline using Python's `Annotated` type hint syntax instead of traditional docstrings.
Textual is a Python framework for building cross-platform user interfaces that run in the terminal or web browser using a modern, component-based API.
Install it if you're developing CLI tools, dashboards, or interactive terminal applications.
Typer builds command-line applications from Python functions using type hints, automatically generating help text, argument parsing, and shell completion.
Install it if you are building CLIs in Python.
Build and connect to Model Context Protocol servers that expose tools, resources, and prompts to LLM applications over stdio, HTTP, or SSE transports.
Install it if you need to build or connect to servers.
Werkzeug is a WSGI utility library providing request/response objects, URL routing, an interactive debugger, HTTP utilities, and a development server for building web applications.
See also greenlet · async_generator · duet · gevent · threadloop · asyncgui · sniffio · synchronicity · asyncer · culsans