but of course, I can’t iterate over get_route_tabl...
# python
p
but of course, I can’t iterate over get_route_tables (or if I encapsulate it inside another async def) because it’s a co-routine
i
Yeah - have you been seeing that it’s a pain to break things into coroutines? It’s a shame that data sources are really the only time when the “async-ness” of Pulumi breaks through and it’s empirically pretty confusing. That said, if you are OK using coroutines, you can use
async for
to iterate over asynchronous generators - do you think that would help in your case?
p
it means that I have to have the async for inside yet another async def 🙂
It’s doable, but clumsy. What I’d really like is if “get_route_tables” returned a list of route53.RouteTables, that can be iterated fine 🙂 The async stuff is sorta clumsy currently, but Python’s async is sorta clumsy in general 🙂 I think what’s needed is a way to hang the classes and functions I create off the same async loop executor so that they are able to be incorporated into the engine when it’s running. But that would mean exposing the pulumi.stack.run_in_stack in some way so that things like async for’s and async defs created by the user are also run
i
It’s doable, but clumsy. What I’d really like is if “get_route_tables” returned a list of route53.RouteTables, that can be iterated fine 🙂
I hear you, but because the rest of Pulumi is so asynchronous, I’m afraid that can’t be done without seriously regressing other aspects of deployment, which is unfortunate. You can use
asyncio.ensure_future
to launch your own async def functions, though - you just have to be sure to hook up the future it returns to Pulumi in some way