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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for greenletio-0.10.1.tar.gz
Algorithm Hash digest
SHA256 cee341b46aed09e7ac4e7731d1df4bce5673548298da309064f8179ac2355017
MD5 9cd946831cf663c7cfaa47fa1c4b659a
BLAKE2b-256 2f623cdfbbd1eb512cc3bb310ee499a7aa5f64472e714214a216ca30f3736aaf

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for greenletio-0.10.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2734404c4962d87d7821753ef003ac4a2c2743aec68d1a550c8e306ecbf3ebd3
MD5 4a3d7b70280cf5b1f1a679123ff4f7d7
BLAKE2b-256 4f8a17ba73ee63ec83a7b232a36ca27a0e4637c89a7f2a21408a56944156e068

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