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.
The following are some of the possibilities when using greenletio
.
import asyncio
from greenletio import async_
@async_
def sync_function(arg):
pass
async def async_function():
await sync_function(42)
asyncio.run(async_function())
from greenletio import await_
async def async_function():
pass
def sync_function():
await_(async_function())
from greenletio import await_
@await_
async def async_function():
pass
def sync_function():
async_function()