Hello, is there a way to make an asyncio task for ...
# automation-api
b
Hello, is there a way to make an asyncio task for things like
Stack.up()
? We’re trying to use an asyncio HTTP framework (aiohttp) and would really like to run those as a task without blocking the http response
e
So, am I guessing right that you want to build a API which triggers
stack.up()
and returns HTTP response before
stack.up()
is ready?
b
yep correct. i was hoping there’s a way to expose an underlying coroutine to use with asyncio.create_task (or a separate api for async usage, or something)
r
There's an open issue for this
But I think you could possibly do this by wrapping the calls in a coroutine yourself
b
wouldn’t they block the entire event loop?
(ty for the issue link btw)
r
yeah possibly, tbh never tried this myself i dunno if what i'm suggesting is realistic
b
AIUI (i’ve got some asyncio experience, but i’m not an expert) there has to be something that’s Awaitable for it to avoid blocking the event loop
it may potentially be not-absurd to wrap it in multiprocessing first
oh neat, i see it’s ultimately just wrapping subprocess, that means it should be fairly straightforward to make an asyncio version …
r
Yeah just keep in mind this caveat: https://github.com/pulumi/pulumi/issues/6052 But as long as they're in different processes you're golden.