✨(backend) force loading celery shared task in libraries
Library we are using can have celery shared task. We have to make some modification to load them earlier when the celery app is configure and when the impress app is loaded.
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
"""Impress package. Import the celery app early to load shared task form dependencies."""
|
||||
|
||||
from .celery_app import app as celery_app
|
||||
|
||||
__all__ = ["celery_app"]
|
||||
|
||||
@@ -11,6 +11,9 @@ os.environ.setdefault("DJANGO_CONFIGURATION", "Development")
|
||||
|
||||
install(check_options=True)
|
||||
|
||||
# Can not be loaded only after install call.
|
||||
from django.conf import settings # pylint: disable=wrong-import-position
|
||||
|
||||
app = Celery("impress")
|
||||
|
||||
# Using a string here means the worker doesn't have to serialize
|
||||
@@ -20,4 +23,4 @@ app = Celery("impress")
|
||||
app.config_from_object("django.conf:settings", namespace="CELERY")
|
||||
|
||||
# Load task modules from all registered Django apps.
|
||||
app.autodiscover_tasks()
|
||||
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
|
||||
|
||||
Reference in New Issue
Block a user