Use direct __await__()
call:
async def new_sleep():
await asyncio.sleep(2)
class Waiting:
def __await__(self):
return new_sleep().__await__()
The solution was recommended by Yury Selivanov (the author of PEP 492) for aioodbc library
More Related Contents:
- How to use asyncio with existing blocking library?
- Simplest async/await example possible in Python
- Combine awaitables like Promise.all
- How to call an async function without await?
- Using asyncio.Queue for producer-consumer flow
- How does asyncio actually work?
- How to limit concurrency with Python asyncio?
- How can I periodically execute a function with asyncio?
- Python 3.7 – asyncio.sleep() and time.sleep()
- asyncio.sleep() vs time.sleep()
- multiprocessing vs multithreading vs asyncio in Python 3
- Asyncio.gather vs asyncio.wait
- How can I send an HTTP request from my FastAPI app to another site (API)?
- How to test Python 3.4 asyncio code?
- How can I wrap a synchronous function in an async coroutine?
- Does asyncio supports asynchronous I/O for file operations?
- What does “SSLError: [SSL] PEM lib (_ssl.c:2532)” mean using the Python ssl library?
- asyncio.sleep() vs time.sleep() in Python
- How can I run an async function using the schedule library?
- multiprocessing vs multithreading vs asyncio
- asyncio.ensure_future vs. BaseEventLoop.create_task vs. simple coroutine?
- How to use await in a python lambda
- How to set class attribute with await in __init__
- Is there a way to use asyncio.Queue in multiple threads?
- Create generator that yields coroutine results as the coroutines finish
- “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?
- How to combine Celery with asyncio?
- Why is dictionary ordering non-deterministic?