Asyncio integration with sync code using greenlets.
Project description
greenletio
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
Release history Release notifications | RSS feed
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.1.0.tar.gz
(12.0 kB
view details)
Built Distribution
File details
Details for the file greenletio-0.1.0.tar.gz
.
File metadata
- Download URL: greenletio-0.1.0.tar.gz
- Upload date:
- Size: 12.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3719d2d7bc43aa64743d4d183c0f24620ce98f25a728d18f642a0e8e7021e031 |
|
MD5 | 31659385253510a5b8bd9569dd3f390a |
|
BLAKE2b-256 | ab76eb846c81a153f305ed9b429dda4b20030ba4863b5c2c9ccb587e4a0b2294 |
File details
Details for the file greenletio-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: greenletio-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 70e8c154c582cfc4b612b722d4265d662acf23308fe257098a0dd694b55dfee5 |
|
MD5 | 91b84e0abf357ed1d313bcc5e1b99121 |
|
BLAKE2b-256 | 4d1e243358c6ae355be3441ae284420308cd5a2617303342ecff930cdff34495 |