millions-addition-49065
03/07/2023, 2:50 AMComponent
unit tests to behave correctly in a python/pytest project that has other async-based unit tests (FastAPI). The pulumi-specific tests behave fine by themselves, but introducing my other tests into the same pytest session causes problems. Everything is using asyncio/anyio. I end up getting the dreaded attached to a different loop exception after some hanging. I have tried forcing a single event loop with various pytest fixtures. Sometimes I’ve been able to get to work, but without consistency. I understand pulumi is doing some “interesting” things behind the scene with python async and event loops, but is there any hope in making it play nicely with other async pytests? Hoping someone has some secret sauce that I haven’t thought of yet. I’d like to be able to keep the tests together if possible.
Some exception examples:
Exception ignored in: <coroutine object Output.apply.<locals>.run at 0xffff7c22c460>
Traceback (most recent call last):
File "/.pyenv/versions/3.11.2/lib/python3.11/site-packages/pulumi/output.py", line 228, in run
result_resources.set_result(resources)
File "/.pyenv/versions/3.11.2/lib/python3.11/asyncio/base_events.py", line 761, in call_soon
self._check_closed()
File "/.pyenv/versions/3.11.2/lib/python3.11/asyncio/base_events.py", line 519, in _check_closed
raise RuntimeError('Event loop is closed')
Traceback (most recent call last):
File "/.pyenv/versions/3.11.2/lib/python3.11/site-packages/pulumi/runtime/rpc_manager.py", line 71, in rpc_wrapper
result = await rpc
^^^^^^^^^
File "/.pyenv/versions/3.11.2/lib/python3.11/site-packages/pulumi/runtime/resource.py", line 811, in do_register
resolver = await prepare_resource(res, ty, custom, remote, props, opts, typ)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/.pyenv/versions/3.11.2/lib/python3.11/site-packages/pulumi/runtime/resource.py", line 187, in prepare_resource
parent_urn = await opts.parent.urn.future()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/.pyenv/versions/3.11.2/lib/python3.11/site-packages/pulumi/output.py", line 128, in get_value
val = await self._future
^^^^^^^^^^^^^^^^^^
RuntimeError: await wasn't used with future
RuntimeError: Task <Task pending name='Task-116' coro=<Output.future.<locals>.get_value() running at /.pyenv/versions/3.11.2/lib/python3.11/site-packages/pulumi/output.py:128> cb=[Task.task_wakeup()]> got Future <Future pending> attached to a different loop
Thread in Slack Conversation