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.0.tar.gz (16.0 kB view details)

Uploaded Source

Built Distribution

greenletio-0.10.0-py3-none-any.whl (14.1 kB view details)

Uploaded Python 3

File details

Details for the file greenletio-0.10.0.tar.gz.

File metadata

  • Download URL: greenletio-0.10.0.tar.gz
  • Upload date:
  • Size: 16.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.15

File hashes

Hashes for greenletio-0.10.0.tar.gz
Algorithm Hash digest
SHA256 67c37cfd6f7fa12d7988c4932a6d30f9ef5f3d3477f6744ab363921f0431740c
MD5 d26b1e3b9d32b44ae5d7b79288763c2f
BLAKE2b-256 6b32d460fd7eb683ed7bb7ee35c02b74e1fd2ac2b9cad0ea11f0f359ab75a8e8

See more details on using hashes here.

File details

Details for the file greenletio-0.10.0-py3-none-any.whl.

File metadata

  • Download URL: greenletio-0.10.0-py3-none-any.whl
  • Upload date:
  • Size: 14.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.15

File hashes

Hashes for greenletio-0.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 52199c2030fb7011fc10ac191329bba1b356b039ba1735970180bb7dd7c05b9a
MD5 a5dad26cb18394c54295aa8ec913d58e
BLAKE2b-256 2b88af18722a1a01139b2e14574b7b21e0eef622e90f87e565cd7a6ac4a68e95

See more details on using hashes here.

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