Dependency injection in background callbacks

i am using dependency_injector library to inject db connection. With normal callbacks the wiring is happening correctly and DB injection works. However, there seems to be a problem while using background callbacks.

I am instantiating background callbacks like below in app.py. However, using @inject decorator does not convert session_factory into dynamic session_factory object. Any guidance, where to do the wiring so that it works with background callbacks?

session_factory: db.AppContainer = Provide[db.AppContainer.session_factory]

if os.name == “nt”:
launch_uid = uuid4()
disk_cache = diskcache.Cache(“./cache”)
long_callback_manager = DiskcacheLongCallbackManager(disk_cache, cache_by=[lambda: launch_uid], expire=60)
background_callback_manager = DiskcacheManager(disk_cache)
else:
celery_app = Celery(
name, broker=“redis://localhost:6379/1”, backend=“redis://localhost:6379/2”, include=[‘callbacks’]
)
long_callback_manager = CeleryLongCallbackManager(celery_app)
background_callback_manager = CeleryManager(celery_app)

Did you ever find the solution to this problem?

I used a workaround by doing the wiring in the container itself like below
wiring_config = containers.WiringConfiguration(modules=[“XYZ”])

This allowed injection in the background callbacks.
Ideally it will be great to know where exactly should the wiring happen possibly in celery since this is what background callback is using i suppose.

Is the code open s.t. it’s possible to have a look at the entire container setup?