Skip to main content

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 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pysynchronizer-1.0.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pysynchronizer-1.0-py3-none-any.whl (17.8 kB view details)

Uploaded Python 3

File details

Details for the file pysynchronizer-1.0.tar.gz.

File metadata

  • Download URL: pysynchronizer-1.0.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.3

File hashes

Hashes for pysynchronizer-1.0.tar.gz
Algorithm Hash digest
SHA256 b2f09c7a364a71bd30ec7c20aa45376ece222a6bcff5a072f4079f4f58bb0a6c
MD5 b66df78aec2d3e2fb9745aa4512f4b38
BLAKE2b-256 9fc2f09dde58c69fbbf1ce748f969cf148544d68629dde1c2e46585b2b2f9251

See more details on using hashes here.

File details

Details for the file pysynchronizer-1.0-py3-none-any.whl.

File metadata

  • Download URL: pysynchronizer-1.0-py3-none-any.whl
  • Upload date:
  • Size: 17.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.3

File hashes

Hashes for pysynchronizer-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aaafb0eb38d7087d474accb96a2b39a3c11af2bf1f60d5dd95c3608035eab10d
MD5 eb33eda09b55c576a832817200a69a3b
BLAKE2b-256 6eaa9d85a4bd91b82eaad5d6e1664c8b69e52fdf3e4c7b3c9798831dbdc15035

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page