Asyncio integration with sync code using greenlets.
- Python 97.7%
- Shell 2.3%
|
All checks were successful
build / tests-3.11 (push) Successful in 50s
build / tests-3.10 (push) Successful in 51s
build / tests-3.12 (push) Successful in 53s
build / zizmor (push) Successful in 8s
build / lint (push) Successful in 1m10s
build / tests-3.13 (push) Successful in 34s
build / tests-3.14 (push) Successful in 35s
|
||
|---|---|---|
| .forgejo/workflows | ||
| benchmarks | ||
| docs | ||
| examples | ||
| src/greenletio | ||
| tests | ||
| .coveragerc | ||
| .gitignore | ||
| .readthedocs.yaml | ||
| CHANGES.md | ||
| CODE_OF_CONDUCT.md | ||
| CONTRIBUTING.md | ||
| LICENSE | ||
| MANIFEST.in | ||
| pyproject.toml | ||
| README.md | ||
| SECURITY.md | ||
| tox.ini | ||
greenletio
This project allows synchronous and asynchronous functions to be used together.
Unlike other methods based on executors and thread or process pools,
greenletio allows synchronous functions to work like their asynchronous
counterparts, without the need to create expensive threads or processes.
Examples
The following are some of the possibilities when using greenletio.
Convert a sync function into an awaitable
import asyncio
from greenletio import async_
@async_
def sync_function(arg):
pass
async def async_function():
await sync_function(42)
asyncio.run(async_function())
Use await inside a sync function
from greenletio import await_
async def async_function():
pass
def sync_function():
await_(async_function())
Call an async function as a normal function
from greenletio import await_
@await_
async def async_function():
pass
def sync_function():
async_function()
Resources
Sponsor this project
This project relies on contributions from its users. If you benefit from it please consider making a single or ongoing monetary contribution in one of the following platforms:
Thank you!