Skip to content

Commit

Permalink
Allow DequeueByPctStrategy to deal with empty queues.
Browse files Browse the repository at this point in the history
  • Loading branch information
asciipip committed Jul 6, 2012
1 parent de2906e commit dde2ab9
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions dequeue.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ def getMessage(self):
# queue. We try to make the time-spent-rendering percentages match the
# weighted queue percentages.
weighted_queues = [ self.chan.queue_declare(queue='toposm_z{0}'.format(z), passive=True)[1] * pow(4, z) / pow(NTILES[z], 2) for z in range(0, self.maxz + 1) ]
if sum(weighted_queues) == 0:
return None
queue_pcts = [ float(t) / sum(weighted_queues) for t in weighted_queues ]
render_sum = sum(self.render_time) if sum(self.render_time) > 0 else 1
render_pcts = [ float(t) / render_sum for t in self.render_time ]
Expand Down

0 comments on commit dde2ab9

Please sign in to comment.