Answer the question
In order to leave comments, you need to log in
Why isn't await firing?
There is this code:
async def callee():
print('Hello')
async def caller():
await callee()
print('World')
caller()
(asyncio) [email protected] ~/.MINT18/code/python/asyncio $ python index.py
index.py:8: RuntimeWarning: coroutine 'caller' was never awaited
caller()
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Answer the question
In order to leave comments, you need to log in
All coroutines (functions using async/await) must be executed in the eventloop. This is exactly what is indicated in the warning that the eventloop was not launched and the coroutine was not called.
The launch of the coroutine can be done like this:
This call must be made for the main function where all asynchronous calls are located.
I understand you forgot to import the library
import asyncio
async def callee():
print('Hello')
async def caller():
await callee()
print('World')
if __name__ == '__main__':
asyncio.run(caller())
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question