Permalink
Browse files

Default for CELERYBEAT_MAX_LOOP_INTERVAL now set by individual schedu…

…lers
  • Loading branch information...
1 parent 7770d4b commit 4cd0a28caaed4ba68ff06cfac049631cd5c3b0cd @ask committed Apr 19, 2012
Showing with 27 additions and 6 deletions.
  1. +1 −1 celery/app/defaults.py
  2. +8 −4 celery/beat.py
  3. +6 −0 celery/schedules.py
  4. +12 −1 docs/configuration.rst
View
2 celery/app/defaults.py
@@ -187,7 +187,7 @@ def to_python(self, value):
"SCHEDULE": Option({}, type="dict"),
"SCHEDULER": Option("celery.beat.PersistentScheduler"),
"SCHEDULE_FILENAME": Option("celerybeat-schedule"),
- "MAX_LOOP_INTERVAL": Option(5 * 60, type="float"),
+ "MAX_LOOP_INTERVAL": Option(0, type="float"),
"LOG_LEVEL": Option("INFO", deprecate_by="2.4", remove_by="3.0"),
"LOG_FILE": Option(deprecate_by="2.4", remove_by="3.0"),
},
View
12 celery/beat.py
@@ -40,6 +40,8 @@
logger = get_logger(__name__)
debug, info, error = logger.debug, logger.info, logger.error
+DEFAULT_MAX_INTERVAL = 300 # 5 minutes
+
class SchedulingError(Exception):
"""An error occured while scheduling a task."""
@@ -154,8 +156,9 @@ def __init__(self, schedule=None, max_interval=None,
app=None, Publisher=None, lazy=False, **kwargs):
app = self.app = app_or_default(app)
self.data = maybe_promise({} if schedule is None else schedule)
- self.max_interval = max_interval or \
- app.conf.CELERYBEAT_MAX_LOOP_INTERVAL
+ self.max_interval = (max_interval
+ or app.conf.CELERYBEAT_MAX_LOOP_INTERVAL
+ or DEFAULT_MAX_INTERVAL)
self.Publisher = Publisher or app.amqp.TaskPublisher
if not lazy:
self.setup_schedule()
@@ -377,8 +380,9 @@ class Service(object):
def __init__(self, max_interval=None, schedule_filename=None,
scheduler_cls=None, app=None):
app = self.app = app_or_default(app)
- self.max_interval = max_interval or \
- app.conf.CELERYBEAT_MAX_LOOP_INTERVAL
+ self.max_interval = (max_interval
+ or app.conf.CELERYBEAT_MAX_LOOP_INTERVAL
+ or DEFAULT_MAX_INTERVAL)
self.scheduler_cls = scheduler_cls or self.scheduler_cls
self.schedule_filename = schedule_filename or \
app.conf.CELERYBEAT_SCHEDULE_FILENAME
View
6 celery/schedules.py
@@ -64,6 +64,12 @@ def is_due(self, last_run_at):
:setting:`CELERYBEAT_MAX_LOOP_INTERVAL` if responsiveness is of
importance to you.
+ .. admonition:: Scheduler max interval variance
+
+ The default max loop interval may vary for different schedulers.
+ For the default scheduler the value is 5 minutes, but for e.g.
+ the django-celery database scheduler the value is 5 seconds.
+
"""
rem_delta = self.remaining_estimate(last_run_at)
rem = timedelta_seconds(rem_delta)
View
13 docs/configuration.rst
@@ -1563,7 +1563,18 @@ CELERYBEAT_MAX_LOOP_INTERVAL
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The maximum number of seconds :mod:`~celery.bin.celerybeat` can sleep
-between checking the schedule. Default is 300 seconds (5 minutes).
+between checking the schedule.
+
+
+The default for this value is scheduler specific.
+For the default celerybeat scheduler the value is 300 (5 minutes),
+but for e.g. the django-celery database scheduler it is 5 seconds
+because the schedule may be changed externally, and so it must take
+changes to the schedule into account.
+
+Also when running celerybeat embedded (:option:`-B`) on Jython as a thread
+the max interval is overridden and set to 1 so that it's possible
+to shut down in a timely manner.
.. _conf-celerymon:

0 comments on commit 4cd0a28

Please sign in to comment.