Skip to content

Commit

Permalink
[Fix zmap#56]: Fixed custom settings not being read from celery confi…
Browse files Browse the repository at this point in the history
…guration
  • Loading branch information
P-T-I committed May 15, 2020
1 parent 6462455 commit e01f400
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions celerybeatmongo/schedulers.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,24 +106,27 @@ class MongoScheduler(Scheduler):
Model = PeriodicTask

def __init__(self, *args, **kwargs):
if hasattr(current_app.conf, "mongodb_scheduler_db"):
db = current_app.conf.get("mongodb_scheduler_db")
elif hasattr(current_app.conf, "CELERY_MONGODB_SCHEDULER_DB"):
db = current_app.conf.CELERY_MONGODB_SCHEDULER_DB

Scheduler.__init__(self, *args, **kwargs)

if hasattr(self.app.conf, "mongodb_scheduler_db"):
db = self.app.conf.get("mongodb_scheduler_db")
elif hasattr(self.app.conf, "CELERY_MONGODB_SCHEDULER_DB"):
db = self.app.conf.CELERY_MONGODB_SCHEDULER_DB
else:
db = "celery"

if hasattr(current_app.conf, "mongodb_scheduler_connection_alias"):
alias = current_app.conf.get('mongodb_scheduler_connection_alias')
elif hasattr(current_app.conf, "CELERY_MONGODB_SCHEDULER_CONNECTION_ALIAS"):
alias = current_app.conf.CELERY_MONGODB_SCHEDULER_CONNECTION_ALIAS
if hasattr(self.app.conf, "mongodb_scheduler_connection_alias"):
alias = self.app.conf.get('mongodb_scheduler_connection_alias')
elif hasattr(self.app.conf, "CELERY_MONGODB_SCHEDULER_CONNECTION_ALIAS"):
alias = self.app.conf.CELERY_MONGODB_SCHEDULER_CONNECTION_ALIAS
else:
alias = "default"

if hasattr(current_app.conf, "mongodb_scheduler_url"):
host = current_app.conf.get('mongodb_scheduler_url')
elif hasattr(current_app.conf, "CELERY_MONGODB_SCHEDULER_URL"):
host = current_app.conf.CELERY_MONGODB_SCHEDULER_URL
if hasattr(self.app.conf, "mongodb_scheduler_url"):
host = self.app.conf.get('mongodb_scheduler_url')
elif hasattr(self.app.conf, "CELERY_MONGODB_SCHEDULER_URL"):
host = self.app.conf.CELERY_MONGODB_SCHEDULER_URL
else:
host = None

Expand All @@ -135,9 +138,9 @@ def __init__(self, *args, **kwargs):
else:
logger.info("backend scheduler using %s/%s:%s",
"mongodb://localhost", db, self.Model._get_collection().name)

self._schedule = {}
self._last_updated = None
Scheduler.__init__(self, *args, **kwargs)
self.max_interval = (kwargs.get('max_interval')
or self.app.conf.CELERYBEAT_MAX_LOOP_INTERVAL or 5)

Expand Down

0 comments on commit e01f400

Please sign in to comment.