Skip to main content

Python package that makes it easy to run fast asyncio code

Project description

asyncio-anywhere

Python package that makes it easy to run fast asyncio code

PyPI version Release Notes pytest Poetry

Are you trying to run async code in Python and getting the error asyncio.run() cannot be called from a running event loop? This package makes it easy to run asyncio-based async code in tricky execution environments:

  • IPython-based notebooks (JupyterLab, AWS Sagemaker, Databricks, etc)
  • trio applications
  • curio applications

Other Features:

  • Use uvloop for faster i/o - but without permanently changing the asyncio event loop policy
  • Run any code which uses asyncio I/O.
  • Type hints to support type-aware IDEs

Non-Features:

  • asyncio-anywhere does not monkey-patch the asyncio module. This avoids unexpected side-effects and potential future bugs.

Usage

pip install asyncio-anywhere
import asyncio
from asyncio_anywhere import asyncio_run


async def myfunc():
    await asyncio.sleep(0.01)
    return "OK"


result = asyncio_run(myfunc())

print(result)

Use asyncio_run() anywhere where you would normally have run asyncio.run(). Note that it also accepts a boolean debug parameter as the second parameter.

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

asyncio_anywhere-0.2.0.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

asyncio_anywhere-0.2.0-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file asyncio_anywhere-0.2.0.tar.gz.

File metadata

  • Download URL: asyncio_anywhere-0.2.0.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.9.18 Darwin/22.6.0

File hashes

Hashes for asyncio_anywhere-0.2.0.tar.gz
Algorithm Hash digest
SHA256 5edcf2299978571c35e1b108d8b319a94192bd033037725a191ff317ca0da3c0
MD5 3f1eb2f4ca2a475df4e93090b6f5daa4
BLAKE2b-256 ddb73f112a13354727538147119987dcb77bc619b46c325ea6c96c30c48f0a69

See more details on using hashes here.

File details

Details for the file asyncio_anywhere-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for asyncio_anywhere-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9cd0b9c5408dfb1334509f881f027ab118847b55bfd6226377531fbfe144c8be
MD5 533ab6e50645ec126bc02dc051eee988
BLAKE2b-256 5c01533fb8dfb1933676450fb4a8746ad929dcbeebe20faf916870942527c02e

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