diff --git a/alerts/celeryconfig.py b/alerts/celeryconfig.py index 950e6ab2..503d31ea 100644 --- a/alerts/celeryconfig.py +++ b/alerts/celeryconfig.py @@ -1,4 +1,5 @@ from celery import Celery +from importlib import import_module from lib.config import ALERTS, LOGGING, RABBITMQ from logging.config import dictConfig @@ -54,5 +55,15 @@ app = Celery('alerts', include=alerts_include) app.config_from_object('celeryconfig', force=True) +# As a result of celery 3 to celery 4, we need to dynamically +# register all of the alert tasks specifically +for alert_namespace in CELERYBEAT_SCHEDULE: + alert_tokens = alert_namespace.split('.') + alert_module_name = alert_tokens[0] + alert_classname = alert_tokens[1] + alert_module = import_module(alert_module_name) + alert_class = getattr(alert_module, alert_classname) + app.register_task(alert_class()) + if __name__ == '__main__': app.start()