Merge pull request #182 from bob-r/configurable_guard_cycle

Guard loop sleep made configurable
This commit is contained in:
Ilan Steemers
2016-07-21 15:18:51 +02:00
committed by GitHub
3 changed files with 12 additions and 2 deletions

View File

@@ -208,7 +208,7 @@ class Sentinel(object):
logger.info(_('Q Cluster-{} running.').format(self.parent_pid))
scheduler(broker=self.broker)
counter = 0
cycle = 0.5 # guard loop sleep in seconds
cycle = Conf.GUARD_CYCLE # guard loop sleep in seconds
# Guard loop. Runs at least once
while not self.stop_event.is_set() or not counter:
# Check Workers
@@ -228,7 +228,7 @@ class Sentinel(object):
self.reincarnate(self.pusher)
# Call scheduler once a minute (or so)
counter += cycle
if counter == 30 and Conf.SCHEDULER:
if counter >= 30 and Conf.SCHEDULER:
counter = 0
scheduler(broker=self.broker)
# Save current status

View File

@@ -71,6 +71,11 @@ class Conf(object):
# Failures are always saved
SAVE_LIMIT = conf.get('save_limit', 250)
# Guard loop sleep in seconds
GUARD_CYCLE = conf.get('guard_cycle', 0.5)
if GUARD_CYCLE <= 0 or GUARD_CYCLE >= 60:
raise ValueError('`guard_cycle` must be greater than 0 and less than 60 sec')
# Disable the scheduler
SCHEDULER = conf.get('scheduler', True)

View File

@@ -78,6 +78,11 @@ Limits the amount of successful tasks saved to Django.
- Defaults to ``250``
- Failures are always saved.
guard_cycle
~~~~~~~~~~~
Guard loop sleep in seconds, must be greater than 0 and less than 60.
.. _sync:
sync