Skip to main content

asyncr

PyPI PyPI - Downloads

asyncr is a Python library for helping you handle those pesky async functions with ease! With asyncr you can easily run your async functions in a synchronous way or run your synchronous functions in an async way.

Installation

Use the package manager pip to install asyncr.

pip install asyncr

Usage

from asyncio import get_event_loop

from asyncr import as_sync, as_async


# Create a new async function and wrap it with as_sync, now it will be a sync function.
@as_sync
async def async_function():
    return "Hello, Sync World!"


print(async_function())


# Create a new sync function and wrap it with as_async, now it will be an async function.
@as_async
def sync_function():
    return "Hello, Async World!"


print(get_event_loop().run_until_complete(sync_function()))

You can also pass a the loop for running the functions as the parameter for the decorator. If no loop is provided, the default loop will be used.

from asyncio import get_event_loop, new_event_loop

from asyncr import as_sync, as_async


# Create a new async function and wrap it with as_sync, now it will be a sync function.
@as_sync(new_event_loop())
async def async_function():
    return "Hello, Sync World!"

print(async_function())

Contributing

Please open an issue first to discuss what you would like to change. I welcome any and all criticism, feedback, and suggestions even if I may not agree.

Metadata

Release files for asyncr 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for asyncr 0.1.0
File Size Uploaded
asyncr-0.1.0.tar.gz 7.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for asyncr 0.1.0
File Interpreter ABI Platform
asyncr-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 13.9 kB

Release files / asyncr-0.1.0.tar.gz

Download URL asyncr-0.1.0.tar.gz
Size 7.3 kB
Tags Source
SHA-256 checksum
How to use checksums
ba574de42bafefa5b0d9113a7e976e799288cf7cc06c48c7472264030b68756e
BLAKE2b-256 checksum
How to use checksums
37927843222e56322df85c244cf7845a131321421ef60c09caf26891e2ef3e40
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.11.7

Release files / asyncr-0.1.0-py3-none-any.whl

Download URL asyncr-0.1.0-py3-none-any.whl
Size 6.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dca1f698c678fb17d0f2cdfd4e37780c55fa4f1bbba490fda2e12eef216fb9a4
BLAKE2b-256 checksum
How to use checksums
9369cc01149e7ebd9576cc0d1f09f4a09b66a9e596b30ac1bd6f6c116dfb4538
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.11.7

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page