incalculable-soccer-97284
12/09/2018, 9:19 PMResource
be made Awaitable, roughly:
class Resource():
def __await__(self):
return self.id.future()__await__
This allows me to manage my resources in async more conveniently, including I/O packaging my series of lambda src code. Wdyt?
Obviously we need an async version of register_resource()
and externalizing loop may feel icky.white-balloon-205
Output
and apply
. Our goal is that you rarely would want/need to be exposed to the asynchrony directly, though it’s always interesting to understand use cases where it may be helpful.
There’s also an additional subtlety that we track dependency information through this same data flow, so offering ways to peak behind the abstraction can lead to loss of accurate dependency tracking, which we’re trying to make sure is something you just get for free from writing Pulumi programs naturally.incalculable-soccer-97284
12/10/2018, 7:51 PMapply
and the code should show you why.
RE lossy dependency metadata: I've been thinking about this as well and understand the need to support the synchronous programming model. I see __await__
as an additional hook to augment the pre-existing dependency metadata captured as Output
dependencies. I believe it should enable both sync and async programming model. I'm sure the devil's in the details. The code I'm sending you would clarify what I meant.incalculable-sundown-82514
12/10/2018, 7:53 PMincluding I/O packaging my series of lambda src codeYou should be able to pass anything awaitable as an input to a
Resource
- is that what you’d like to do here? Do some sort of I/O asynchronously and then use the data from I/O for a resource?incalculable-soccer-97284
12/10/2018, 7:59 PMapply
to be limiting when building the SFN definition that depends on multiple instances of lambda.arn
incalculable-sundown-82514
12/10/2018, 8:01 PMpulumi.all
which accepts a list of outputs and produces an output of a list. It makes it way easier to compose multiple outputs like that.
We should probably include a combinator like that in Python, too, since it’s super useful.pulumi.all(arn1, arn2, arn3).apply(lambda arns: do_something_with_arns(arns))
incalculable-soccer-97284
12/10/2018, 8:05 PMawait
for pulumi `Resource`s. Perhaps instead of ended with asyncio.ensure_futures(coro)
we swap it with pulumi's coro registration api. This way I'm not limited to apply
and Output
API.incalculable-sundown-82514
12/10/2018, 8:06 PMapply
and the asynchronous resolution of output properties to do this. If you were able to await
a Resource and get its properties directly, you’d be able to defeat our dependency tracking.incalculable-soccer-97284
12/10/2018, 8:09 PM__await__
on Resource
can be used as a hook to augment the pre-existing dependency graph.
Possibly with the help of custom executor, pulumi decorators or perhaps stacktrace (hopefully not). I'm brainstorming, but am just curious if you have plans to bring full async programming to the hands of the clients.pulumi.all
will make it into the SDK?incalculable-sundown-82514
12/10/2018, 11:00 PMincalculable-soccer-97284
12/11/2018, 8:57 PMincalculable-sundown-82514
12/12/2018, 5:52 AM