big-glass-16858
05/10/2019, 1:51 PMRuntimeError: asyncio.run() cannot be called from a running event loop
if anyone can point me to the right docs or code, that would be nice 👍big-piano-35669
05/11/2019, 2:39 AMasyncio.run(get_availability_zones())
.
Can you try it without the asyncio.run
? This should still return a promise, but the call to get_availability_zones
already allocates it on the event loop Pulumi is using. So the asyncio.run
shouldn't be necessary, unless I'm missing something.big-glass-16858
05/11/2019, 8:26 AMget_availability_zone()
(actually it's a coroutine
) , we have to resolve it by calling await
but this can only be done in a async
function, and __init__
in python can't be async. I resolved this issue by creating a new event loop and resolving the promise there. I'm not a python expert but other techniques I've seen involve creating a factory to actually create the object, I choose the separated event loop because I think it is actually more understandable and easy to use for other devs. Thank you.