-
-
Notifications
You must be signed in to change notification settings - Fork 339
Open
Labels
Description
For Dependency Injector versions 4.48.0 and above, the app variable is initialized as an instance of _asyncio.Task:
from faststream import FastStream
from faststream.rabbit import RabbitBroker
from dependency_injector import containers, providers
class DI(containers.DeclarativeContainer):
broker = providers.Resource(
RabbitBroker,
)
app = providers.Resource(
FastStream,
broker=broker,
)
di = DI()
di.init_resources()
app = di.app()
print(type(app))However, if we change the broker provider type from Resource to Factory, the app variable correctly returns an instance of faststream.app.FastStream (as expected):
from faststream import FastStream
from faststream.rabbit import RabbitBroker
from dependency_injector import containers, providers
class DI(containers.DeclarativeContainer):
broker = providers.Factory(
RabbitBroker,
)
app = providers.Resource(
FastStream,
broker=broker,
)
di = DI()
di.init_resources()
app = di.app()
print(type(app))In Dependency Injector versions 4.47.1 and below, the app variable consistently returns an instance of faststream.app.FastStream, regardless of whether the broker is initialized as Resource or Factory.
Question: Why does Dependency Injector 4.48.0+ return an _asyncio.Task instance instead of faststream.app.FastStream when using providers.Resource?
Current Workaround: We've temporarily resolved the issue by downgrading to Dependency Injector version 4.47.1.