You can only use await
in an async
enviroment. Try changing the function to asnyc
:
import asyncio
whatever = . . .
async def function(param) -> asyncio.coroutine:
await param
asyncio.run(function(whatever))
Simple and easy.
More Related Contents:
- When to use and when not to use Python 3.5 `await` ?
- “Fire and forget” python async/await
- Asynchronous method call in Python?
- How to limit concurrency with Python asyncio?
- multiprocessing vs multithreading vs asyncio in Python 3
- Asyncio.gather vs asyncio.wait
- When using asyncio, how do you allow all running tasks to finish before shutting down the event loop
- Timeout for python coroutines
- “Asyncio Event Loop is Closed” when getting loop
- Can an asyncio event loop run in the background without suspending the Python interpreter?
- How do I run Python asyncio code in a Jupyter notebook?
- Combine awaitables like Promise.all
- What kind of problems (if any) would there be combining asyncio with multiprocessing?
- How can I wrap a synchronous function in an async coroutine?
- How to use ‘yield’ inside async function?
- What does “SSLError: [SSL] PEM lib (_ssl.c:2532)” mean using the Python ssl library?
- asyncio.sleep() vs time.sleep() in Python
- asyncio: Is it possible to cancel a future been run by an Executor?
- Mocking async call in python 3.5
- Use asyncio and Tkinter (or another GUI lib) together without freezing the GUI
- How to do multiprocessing in FastAPI
- How to set class attribute with await in __init__
- What’s the correct way to clean up after an interrupted event loop?
- aiohttp: set maximum number of requests per second
- How can I await inside future-like object’s __await__?
- Prompt for user input using python asyncio.create_server instance
- Why am I getting NotImplementedError with async and await on Windows?
- “asyncio.run() cannot be called from a running event loop” when using Jupyter Notebook
- Exception event loop is closed with aiohttp and asyncio in python 3.8
- how to add a coroutine to a running asyncio loop?