I was watching your PyGotham talk, "The Other Async" and I was looking that the diabolical crazyness of the universal queue thingy, and suddenly I went hmmmm.. why.. are you awaiting asyncio.wait_for?
Asyncio already knows how to await a wrapped future, so unless I am missing something doing await wait_for(f, None) does nothing for you. Basically there is no point in using wait_for unless you provide a timeout.
Example:
import asyncio
from concurrent.futures import Future
import time
from threading import Thread
f = Future()
def set_delayed(item, delay):
time.sleep(delay)
f.set_result(item)
Thread(target=lambda:set_delayed('Hi David!', 10)).start()
async def get_future():
print(await asyncio.wrap_future(f))
asyncio.get_event_loop().run_until_complete(get_future())
Hi David! (et. al)
I was watching your PyGotham talk, "The Other Async" and I was looking that the diabolical crazyness of the universal queue thingy, and suddenly I went hmmmm.. why.. are you awaiting asyncio.wait_for?
Asyncio already knows how to await a wrapped future, so unless I am missing something doing
await wait_for(f, None)
does nothing for you. Basically there is no point in using wait_for unless you provide a timeout.Example:
You can just wrap the future and await it.