syrusakbary/promise

AsyncioScheduler wait() method doesn't actually wait

minznerjosh opened this issue · 0 comments

def wait(self, promise, timeout=None):
e = Event()
def on_resolve_or_reject(_):
e.set()
promise._then(on_resolve_or_reject, on_resolve_or_reject)
# We can't use the timeout in Asyncio event
e.wait()

As per the docs, the Event.wait() method returns a coroutine. So in order to block function execution it would need to be awaited from another coroutine.

The end result is that the Promise.get() method always returns None when using the AsyncioScheduler unless the promise was previously fulfilled.