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
Other Features:
- use uvloop for faster i/o - but without permanently changing the asyncio event loop policy
- type hints to support type-aware IDEs
Non Features:
- asyncio-anywhere 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)
Use asyncio_run()
anwhere where you would normally have run asyncio.run().
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.2.tar.gz
(3.5 kB
view hashes)
Built Distribution
Close
Hashes for asyncio_anywhere-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5c00f4c40d691d76b1b731ed4480eee284a105f64da94fbf7d33793c18eb6625 |
|
MD5 | a91a6cb9a48db14c55d1d9f6d4cdfce6 |
|
BLAKE2b-256 | 3aa96dc8011ae38898f401a3b774621abbad09d589b8cbb30a9a23f3895f131c |