Skip to main content

Asyncio integration with sync code using greenlets.

Project description

greenletio

Build status codecov

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

greenletio-0.10.1.tar.gz (16.4 kB view hashes)

Uploaded Source

Built Distribution

greenletio-0.10.1-py3-none-any.whl (14.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page