Asyncio integration with sync code using greenlets.
  • Python 97.7%
  • Shell 2.3%
Find a file
Miguel Grinberg 56bfb64baa
All checks were successful
build / tests-3.11 (push) Successful in 50s
build / tests-3.10 (push) Successful in 51s
build / tests-3.12 (push) Successful in 53s
build / zizmor (push) Successful in 8s
build / lint (push) Successful in 1m10s
build / tests-3.13 (push) Successful in 34s
build / tests-3.14 (push) Successful in 35s
Update project URLs in metadata
2026-08-29 23:38:42 +01:00
.forgejo/workflows Forgejo migration 2026-08-29 20:55:56 +01:00
benchmarks context switching benchmark 2021-08-21 16:15:11 +01:00
docs Fix typo (#13) 2023-07-12 07:59:05 +01:00
examples async requests example 2020-08-03 12:11:13 +01:00
src/greenletio Python 3.14 support 2026-05-14 23:54:38 +01:00
tests Python 3.14 support 2026-05-14 23:54:38 +01:00
.coveragerc unit tests 2020-07-19 00:16:50 +01:00
.gitignore Python 3.14 support 2026-05-14 23:54:38 +01:00
.readthedocs.yaml Forgejo migration 2026-08-29 20:55:56 +01:00
CHANGES.md Release 0.11.0 2023-11-10 19:33:23 +00:00
CODE_OF_CONDUCT.md Forgejo migration 2026-08-29 20:55:56 +01:00
CONTRIBUTING.md Forgejo migration 2026-08-29 20:55:56 +01:00
LICENSE Initial commit 2020-07-15 12:36:44 +01:00
MANIFEST.in Migrate Python package metadata to pyproject.toml 2023-10-15 13:07:24 +01:00
pyproject.toml Update project URLs in metadata 2026-08-29 23:38:42 +01:00
README.md Forgejo migration 2026-08-29 20:55:56 +01:00
SECURITY.md Forgejo migration 2026-08-29 20:55:56 +01:00
tox.ini CI build updates (#16) 2026-05-14 23:49:59 +01:00

greenletio

tests

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

Sponsor this project

This project relies on contributions from its users. If you benefit from it please consider making a single or ongoing monetary contribution in one of the following platforms:

Thank you!