Browse Source

Adds setting to modify the heartbeat monitor rate: BROKER_HEARTBEAT_CHECKRATE

Ask Solem 12 years ago
parent
commit
6a8221d427
3 changed files with 18 additions and 6 deletions
  1. 1 0
      celery/app/defaults.py
  2. 2 5
      celery/worker/consumer.py
  3. 15 1
      docs/configuration.rst

+ 1 - 0
celery/app/defaults.py

@@ -68,6 +68,7 @@ NAMESPACES = {
         'CONNECTION_RETRY': Option(True, type='bool'),
         'CONNECTION_MAX_RETRIES': Option(100, type='int'),
         'HEARTBEAT': Option(10, type='int'),
+        'HEARTBEAT_CHECKRATE': Option(2.0, type='int'),
         'POOL_LIMIT': Option(10, type='int'),
         'INSIST': Option(False, type='bool',
                          deprecate_by='2.4', remove_by='4.0'),

+ 2 - 5
celery/worker/consumer.py

@@ -103,9 +103,6 @@ from .heartbeat import Heart
 RUN = 0x1
 CLOSE = 0x2
 
-#: Heartbeat check is called every heartbeat_seconds' / rate'.
-AMQHEARTBEAT_RATE = 2.0
-
 #: Prefetch count can't exceed short.
 PREFETCH_COUNT_MAX = 0xFFFF
 
@@ -398,9 +395,9 @@ class Consumer(object):
         hub.update_readers(self.connection.eventmap)
         self.connection.transport.on_poll_init(hub.poller)
 
-    def consume_messages(self, sleep=sleep, min=min, Empty=Empty,
-                         hbrate=AMQHEARTBEAT_RATE):
+    def consume_messages(self, sleep=sleep, min=min, Empty=Empty):
         """Consume messages forever (or until an exception is raised)."""
+        hbrate = self.app.conf.BROKER_HEARTBEAT_CHECKRATE
 
         with self.hub as hub:
             qos = self.qos

+ 15 - 1
docs/configuration.rst

@@ -799,9 +799,23 @@ and this requires the :mod:`amqp` module:
     $ pip install amqp
 
 The default heartbeat value is 10 seconds,
-the heartbeat will then be monitored at double the rate of the heartbeat value
+the heartbeat will then be monitored at the interval specified
+by the :setting:`BROKER_HEARTBEAT_CHECKRATE` setting, which by default is
+double the rate of the heartbeat value
 (so for the default 10 seconds, the heartbeat is checked every 5 seconds).
 
+.. setting:: BROKER_HEARTBEAT_CHECKRATE
+
+BROKER_HEARTBEAT_CHECKRATE
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+:transports supported: ``pyamqp``
+
+At intervals the worker will monitor that the broker has not missed
+too many heartbeats.  The rate at which this is checked is calculated
+by dividing the :setting:`BROKER_HEARTBEAT` value with this value,
+so if the heartbeat is 10.0 and the rate is the default 2.0, the check
+will be performed every 5 seconds (twice the heartbeat sending rate).
+
 .. setting:: BROKER_USE_SSL
 
 BROKER_USE_SSL