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
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
It also seamlessly makes use of uvloop:
- using dependency markers to only install it on supported operating systems
- using uvloop without permanently the asyncio event loop policy
Non Features:
- asyncio-where does not monkey-patch the asyncio module. We want to avoid doing this because it may cause problems in future Python versions
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)
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.1.1.tar.gz
(3.3 kB
view hashes)
Built Distribution
Close
Hashes for asyncio_anywhere-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 15ed9c291a8d5badf12f08653992e109f25ebbcd1ccbf10afb71d84f591f0c83 |
|
MD5 | 2be4dc5d5e5ac013cff16b2a06ed4f52 |
|
BLAKE2b-256 | acab72f2fdecbaad9d82f4c733486f1d9b8bd4f2933545b90e892a209737afc0 |