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

Uploaded Source

Built Distribution

greenletio-0.9.0-py3-none-any.whl (13.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: greenletio-0.9.0.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.7.3

File hashes

Hashes for greenletio-0.9.0.tar.gz
Algorithm Hash digest
SHA256 683f9cac515a5634ed86a3593de5e0039eade78bc48d888fbf7324be1deff929
MD5 8993f9a55000020633370fc1bc40caba
BLAKE2b-256 fa1aa4eee78e090d4a4527d3af4ca4c74bac32b0b9a3ed2e5ae8087b25e6d7e8

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: greenletio-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 13.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.7.3

File hashes

Hashes for greenletio-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 46c768faa9d2a619d9b3fbe853d2227415fb20b9c5ed5cc3986240b64563c376
MD5 20275c19dfb4770e677c0c32a99b4508
BLAKE2b-256 8862f740652608a7a14c43769370882c1a64ce45fa6b55133c9b6c8474429c43

See more details on using hashes here.

Provenance

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