Skip to content

Commit

Permalink
Allow DequeueByFixedPctStrategy to gracefully continue if all queues …
Browse files Browse the repository at this point in the history
…are empty.
  • Loading branch information
asciipip committed Jun 29, 2012
1 parent 86b95c0 commit a12e641
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions dequeue.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,12 @@ def getMessage(self):
render_sum = 1
render_pcts = [ float(c) / render_sum for c in self.render_count ]
# Seed choice with the last queue that has stuff in it.
chosen_queue = -1
for z in range(0, self.maxz + 1):
if queues[z] > 0:
chosen_queue = z
if chosen_queue == -1:
return None
scale = 2**(self.maxz - chosen_queue)
pct_diff = self.queue_pcts[chosen_queue] * scale - render_pcts[chosen_queue]
# See if there's a more-neglected queue.
Expand Down

0 comments on commit a12e641

Please sign in to comment.