Forráskód Böngészése

Default for CELERYBEAT_MAX_LOOP_INTERVAL now set by individual schedulers

Ask Solem 13 éve
szülő
commit
4cd0a28caa
4 módosított fájl, 27 hozzáadás és 6 törlés
  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

+ 1 - 1
celery/app/defaults.py

@@ -187,7 +187,7 @@ NAMESPACES = {
         "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"),
     },

+ 8 - 4
celery/beat.py

@@ -40,6 +40,8 @@ from .utils.log import get_logger
 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 @@ class Scheduler(object):
             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

+ 6 - 0
celery/schedules.py

@@ -64,6 +64,12 @@ class schedule(object):
         :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)

+ 12 - 1
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: