Ошибки asyncio Python

Contents
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

Article author: Andrei Olegovich

Related articles
FastAPI
list comprehension: Абстракция списка
Python
Pydantic
Циклы
asyncio
Ошибки
multiprocessing

Search this site

Subscribe to Telegram channel @aofeed to follow new articles and updates to old ones

Go to channel

@aofeed

Ask a question in the Telegram group

@aofeedchat

Contacts and cooperation:
I recommend our hosting beget.com
Write to info@aredel.com if you:
1. Want to write an article for our site or translate an article into your native language.
2. Want to place thematically relevant ads on the site.
3. Ads on my site pass maximum censorship. If you see an ad block unsuitable for school-age children, shocking or misleading - please contact us by e-mail
4. Found a mistake, inaccuracy, bug, etc. on the site. ... .......
5. Articles can be shared on social media by clicking a network icon: