You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a generator is provided by Factory, I can inject my dependency synchronously, and example_1 below works as expected. When a generator is provided by Singleton, I experience forced asynchronous behavior (why do I get that?) and encounter a bad yield exception (see example_2 below).
Does anyone know why this happens and how I can fix it?
System:
Python 3.9.16
dependency-injector 4.41.0
Exception:
Traceback (most recent call last):
File "issue.py", line 37, in <module>
asyncio.run(example_2())
File "/usr/lib64/python3.9/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/lib64/python3.9/asyncio/base_events.py", line 647, in run_until_complete
return future.result()
File ".venv/lib64/python3.9/site-packages/dependency_injector/wiring.py", line 994, in _patched
return await _async_inject(
File "src/dependency_injector/_cwiring.pyx", line 62, in _async_inject
File "src/dependency_injector/providers.pyx", line 2986, in dependency_injector.providers.BaseSingleton._async_init_instance
File "issue.py", line 8, in generator_factory
yield 1
RuntimeError: Task got bad yield: 1
When a generator is provided by
Factory
, I can inject my dependency synchronously, and example_1 below works as expected. When a generator is provided bySingleton
, I experience forced asynchronous behavior (why do I get that?) and encounter a bad yield exception (see example_2 below).Does anyone know why this happens and how I can fix it?
System:
Python 3.9.16
dependency-injector 4.41.0
Exception:
Program (issue.py):
The text was updated successfully, but these errors were encountered: