Process as many jobs as the queue will give us in a row, sleep for longer in between checks.

This commit is contained in:
yackob03 2013-10-20 03:26:06 -04:00
parent 2c41382f79
commit abb6efda40

View file

@ -18,7 +18,7 @@ def process_work_items():
item = image_diff_queue.get()
if item:
while item:
logger.debug('Queue gave us some work: %s' % item.body)
request = json.loads(item.body)
@ -27,8 +27,9 @@ def process_work_items():
image_diff_queue.complete(item)
else:
logger.debug('No work today.')
item = image_diff_queue.get()
logger.debug('No more work.')
parser = argparse.ArgumentParser(description='Worker daemon to compute diffs')
@ -49,7 +50,7 @@ def start_worker(args):
sched = Scheduler()
sched.start()
sched.add_interval_job(process_work_items, seconds=10)
sched.add_interval_job(process_work_items, seconds=30)
while True:
time.sleep(60 * 60 * 24) # sleep one day, basically forever