A class or decorator to help with asynchronous programming in Python within synchronous contexts.
Project description
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 asynchronizer
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())
In this example, an instance of Asynchronizer
is created. The run
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.
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
Built Distribution
Hashes for pysynchronizer-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ff60ad4b5ec1584f78da63d0c38559bf0eb23ee1783902439ad086baa5801e8 |
|
MD5 | c693e69b85b081a3af73f654fa3ad2f1 |
|
BLAKE2b-256 | e5ae4936d05096b19d980534a1cdc8a9b19c3b52062cdfac3148c702cd0db53d |