12/01/2022, 9:51 AM
Hey, I'm getting the following error when trying to create a Dynamic Provider in pulumi (using
pulumi up
  pulumi:pulumi:Stack (<my-stack>):
    /Users/<my-path>/venv/lib/python3.10/site-packages/grpc/ RuntimeWarning: coroutine 'invoke.<locals>.do_rpc' was never awaited
      return None, False
    RuntimeWarning: Enable tracemalloc to get the object allocation traceback

  pulumi-python:dynamic:Resource (foo):
    error: Exception calling application: There is no current event loop in thread 'ThreadPoolExecutor-0_0'.
and I had no issues with my stack before adding my Dynamic Provider. I've tried with multiple providers but not even the simple
example from the documentation
Dynamic provider code:
import binascii
import os
from typing import Optional

from pulumi import ResourceOptions
from pulumi.dynamic import CreateResult, Resource, ResourceProvider

class RandomProvider(ResourceProvider):
    def create(self, inputs):
        return CreateResult(id_=binascii.b2a_hex(os.urandom(16)), outs={})

class Random(Resource):
    def __init__(self, name: str, opts: Optional[ResourceOptions] = None):
        super().__init__(RandomProvider(), name, {}, opts)

my_resource = Random("foo")
Information from `pulumi about`:
Version      3.48.0
Go Version   go1.19.2
Go Compiler  gc

NAME           VERSION
gcp            6.44.0
google-native  0.27.0
python         unknown

OS       darwin
Version  13.0
Arch     arm64

<...stack resources>

NAME                      VERSION
google-cloud-bigquery     3.4.0
google-cloud-datacatalog  3.9.3
grpcio-status             1.47.0
pip                       22.3.1
pulumi-gcp                6.44.0
pulumi-google-native      0.27.0
schema                    0.7.5
setuptools                65.5.1
wheel                     0.37.1
I've also tried it in a fresh python 3.9.14 environment with the same result. And I tried this: without any luck
So this appeared to be a problem with using DynamicProvider outside the


12/15/2022, 7:12 PM
i'm not sure that issue applies in this scenario. I am able to use a DynamicProvider outside of main, but I do get the same error you are seeing whenever I use an async api call within create method
class ManagedVNetProvider(ResourceProvider):
    def create(self, props):
        client_config = pulumi_azure_native.authorization.get_client_config()
due to the
call i see the exact error as you. when i take it out, the resource provider works fine
.../lib/python3.10/site-packages/grpc/ RuntimeWarning: coroutine 'invoke.<locals>.do_rpc' was never awaited