Can you stop asyncio.sleep() from sleeping? I want to run some code in a coroutine either after waiting 20 seconds or if a Boolean is true, is there any way to do that? I can only think of achieving it like this:
while t < 20 and not value:
asyncio.sleep(1)
t +=1
...
Is there a more pythonic way to do this?
IIUC, you can use
asyncio.Future()+asyncio.wait_for():This prints:
If you change the
task_fnto:Then the result will be: