Ошибки asyncio Python
| RuntimeWarning: coroutine 'x' was never awaited | |
| Похожие статьи |
RuntimeWarning: coroutine was never awaited
Скорее всего корутина вызвана без использования await
import asyncio async def nested(): return 42 async def main(): # Nothing happens if we just call "nested()". # A coroutine object is created but not awaited, # so it *won't run at all*. nested() asyncio.run(main())
C:\Users\Andrei\asyncio\main.py:10: RuntimeWarning: coroutine 'nested' was never awaited nested() RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Чтобы не получать эту ошибку нужно вызывать корутину через await
import asyncio async def nested(): return 42 async def main(): # Let's do it differently now and await it: print(await nested()) # will print "42". asyncio.run(main())
42
Автор статьи: Андрей Олегович
| FastAPI | |
| list comprehension: Абстракция списка | |
| Python | |
| Pydantic | |
| Циклы | |
| asyncio | |
| Ошибки | |
| multiprocessing |