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

Uploaded Source

Built Distribution

greenletio-0.11.0-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for greenletio-0.11.0.tar.gz
Algorithm Hash digest
SHA256 5751773f859ee7c5a8745569af04b27532e2b8bdb170eb224193bebc32f38136
MD5 e0ac720aef20da378250e849a20f836a
BLAKE2b-256 7ebebab6b8bacbc0ed8089deb38bc6dc947a67f7ca5be009dd5bbf4333e1a782

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for greenletio-0.11.0-py3-none-any.whl
Algorithm Hash digest
SHA256 314f6ac301aacca1c94f8d9ec9d509d98381643e7949cb33af9a14bfa0417b2e
MD5 8b9af7eb4cb981301cb675b399566cc6
BLAKE2b-256 1913abbe5bf28eac052c17b6f1dbcd0daf5b6ce26e8f862ef6eacff636b7b77d

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