Process as many jobs as the queue will give us in a row, sleep for longer in between checks.
This commit is contained in:
parent
2c41382f79
commit
abb6efda40
1 changed files with 5 additions and 4 deletions
|
@ -18,7 +18,7 @@ def process_work_items():
|
||||||
|
|
||||||
item = image_diff_queue.get()
|
item = image_diff_queue.get()
|
||||||
|
|
||||||
if item:
|
while item:
|
||||||
logger.debug('Queue gave us some work: %s' % item.body)
|
logger.debug('Queue gave us some work: %s' % item.body)
|
||||||
|
|
||||||
request = json.loads(item.body)
|
request = json.loads(item.body)
|
||||||
|
@ -27,8 +27,9 @@ def process_work_items():
|
||||||
|
|
||||||
image_diff_queue.complete(item)
|
image_diff_queue.complete(item)
|
||||||
|
|
||||||
else:
|
item = image_diff_queue.get()
|
||||||
logger.debug('No work today.')
|
|
||||||
|
logger.debug('No more work.')
|
||||||
|
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description='Worker daemon to compute diffs')
|
parser = argparse.ArgumentParser(description='Worker daemon to compute diffs')
|
||||||
|
@ -49,7 +50,7 @@ def start_worker(args):
|
||||||
sched = Scheduler()
|
sched = Scheduler()
|
||||||
sched.start()
|
sched.start()
|
||||||
|
|
||||||
sched.add_interval_job(process_work_items, seconds=10)
|
sched.add_interval_job(process_work_items, seconds=30)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
time.sleep(60 * 60 * 24) # sleep one day, basically forever
|
time.sleep(60 * 60 * 24) # sleep one day, basically forever
|
||||||
|
|
Reference in a new issue