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)