The following is the code I'm trying to get working:
>>> import asyncio
>>> async def foo(loop, iv):
... await asyncio.sleep(1, loop=loop)
... print(f'done: {iv}')
...
>>> loop = asyncio.get_event_loop()
>>> loop.call_later(2, foo, loop, 10)
<TimerHandle when=36395.554089349 foo(<_UnixSelecto...e debug=False>, 10) at <input>:1>
>>> loop.run_forever()
(Python 3.6)
Basically the foo()
function has some chained async
calls, so this method has to be async
as there is a need to await
for the chained calls. However this method is triggered after a delay, and when one runs this code, the following problem occurs:
/usr/lib64/python3.6/asyncio/events.py:127: RuntimeWarning: coroutine 'foo' was never awaited self._callback(*self._args)
What is the correct way to handle this async
call in the call_later
?