pulumi/sdk
Justin Van Patten 0b1414dc6d
[sdk/python] Fix mocks issue when passing a resource more than once (#6479)
This change avoids `RuntimeError: There is no current event loop in thread '<thread_name>'` errors when passing a resource as an input multiple times when using mocks.

The problem is that when using mocks, we deserialize the gRPC inputs before passing them to the user's mock methods. Deserializing inputs doesn't typically require an event loop, however, during deserialization of resource references, we end up creating some instances of `Future`, which does require an event loop to be present for the current thread. If this is done multiple times for a resource, it's possible that `deserialize_properties` will be called on an asyncio thread that doesn't yet have an event loop, resulting in the error being raised.

The error does not occur when only passing the resource reference once because typically the thread (e.g. `asyncio_0`) used in that case will have already had an event loop created for it due to the use of the internal `_syncawait` when _serializing_ the source resource's properties, which ensures an event loop is set for the thread.

The fix is to ensure an event loop is created for the thread in the mocks implementation before calling `deserialize_properties`.
2021-03-09 13:48:24 -08:00
..
dotnet Upgrading Go to 1.16.x (#6470) 2021-03-09 20:05:23 +00:00
go Upgrading Go to 1.16.x (#6470) 2021-03-09 20:05:23 +00:00
nodejs Upgrading Go to 1.16.x (#6470) 2021-03-09 20:05:23 +00:00
proto Add support for serialized resource references. (#5041) 2020-10-27 10:12:12 -07:00
python [sdk/python] Fix mocks issue when passing a resource more than once (#6479) 2021-03-09 13:48:24 -08:00
go.mod Add a python shim script to work around https://github.com/golang/go/issues/42919 2020-12-07 14:17:45 -08:00
go.sum Upgrading to go-cloud v0.22.0 (#6473) 2021-03-09 18:59:01 +00:00
README.md Updating .NET references 2020-04-27 12:42:11 -07:00

Pulumi Language SDKs

This directory contains the Pulumi SDKs for all supported languages.

Please see the respective READMEs for information about installing and using these libraries:

The language providers work by implementing gRPC interfaces defined in proto/.