Asynchronizer
This repository contains a Python decorator and class that allow you to run asynchronous code from a synchronous context. This can be particularly useful when you need to perform IO-bound tasks such as making HTTP requests, reading from or writing to a database, or interacting with the file system, but you are working within a synchronous context.
Installation
You can install the asynchronizer package using pip. Open your terminal and type:
pip install pysynchronizer
Usage
Here are some examples of how you can use the asynchronizer package.
Using the decorator
from asynchronizer import asynchronize
@asynchronize
async def async_function():
# Your asynchronous code here
async_function()
In the above example, async_function is an asynchronous function decorated with @async_to_sync. This allows it to be called from a synchronous context.
Using the class
from asynchronizer import Asynchronizer
async def async_function():
# Your asynchronous code here
asynchronizer = Asynchronizer()
asynchronizer.run(async_function())
asynchronizer.run_async(async_function())
In this example, an instance of Asynchronizer is created. The run or run_async method is then used to execute async_function from a synchronous context.
Contributing
Contributions are welcome! Please read the CONTRIBUTING.md for details on how to contribute to this project.
License
This project is licensed under the MIT License - see the LICENSE.md file for details.
Metadata
Release files for pysynchronizer 1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pysynchronizer-1.0.tar.gz | 16.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pysynchronizer-1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 34.6 kB
Release files / pysynchronizer-1.0.tar.gz
| Download URL | pysynchronizer-1.0.tar.gz |
|---|---|
| Size | 16.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b2f09c7a364a71bd30ec7c20aa45376ece222a6bcff5a072f4079f4f58bb0a6c
|
|
BLAKE2b-256 checksum How to use checksums |
9fc2f09dde58c69fbbf1ce748f969cf148544d68629dde1c2e46585b2b2f9251
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.12.3
|
Release files / pysynchronizer-1.0-py3-none-any.whl
| Download URL | pysynchronizer-1.0-py3-none-any.whl |
|---|---|
| Size | 17.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
aaafb0eb38d7087d474accb96a2b39a3c11af2bf1f60d5dd95c3608035eab10d
|
|
BLAKE2b-256 checksum How to use checksums |
6eaa9d85a4bd91b82eaad5d6e1664c8b69e52fdf3e4c7b3c9798831dbdc15035
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.12.3
|