Skip to main content

Convert async coroutines to normal python functions

Project description

Convert async coroutine functions to normal ones.

Installation

$ pip install async_to_sync

Usage

import async_to_sync as sync

# an async object method to demonstrate use
class async_class:
    async def sum(self, a, b):
        return a + b
async_object = async_class()

# wrap all async methods of an object
sync_object = sync.methods(async_object)

assert sync_object.sum(1,2) == 3

# wrap a single async callable
sync_function = sync.function(async_object.sum)

assert sync_function(4,5) == 9

# wait for a coroutine
sync_result = sync.coroutine(async_object.sum(6,7))

assert sync_result == 13

# manually stop default event loop
sync.stop()

# manually start default event loop
sync.start()

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

async_to_sync-0.2.3.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

async_to_sync-0.2.3-py2.py3-none-any.whl (3.4 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file async_to_sync-0.2.3.tar.gz.

File metadata

  • Download URL: async_to_sync-0.2.3.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for async_to_sync-0.2.3.tar.gz
Algorithm Hash digest
SHA256 592b07f1644bae56202f13efa6a7b1f048ed9b24eb7c9e927e4064535273fcaa
MD5 0d9e8025785b51936e08ee271abef654
BLAKE2b-256 a00958fe9aab77d1eb62c7a1e8ee33d855588e9a073c1c14026d921cf5fc4e4d

See more details on using hashes here.

File details

Details for the file async_to_sync-0.2.3-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for async_to_sync-0.2.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 af509c8c849e00eff33c4d913b0c96ee93b755fa47d707615970615f41f08470
MD5 9910b9ab4a78e2a2f217578de322bcd8
BLAKE2b-256 7cf41ef6ab8c738ff41076d3f0314b7c8dc7d11c7c8ad825442e5754067d8a3e

See more details on using hashes here.

Supported by

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