Permalink
Browse files

ensure that after applying weights, all queues are represented in the…

… blpop command
  • Loading branch information...
1 parent e65c6fc commit bceacec766913340a50768d1fe0d9eb82645e74d @ryanlecompte ryanlecompte committed Apr 4, 2012
Showing with 4 additions and 4 deletions.
  1. +4 −4 lib/sidekiq/fetch.rb
View
8 lib/sidekiq/fetch.rb
@@ -16,7 +16,7 @@ class Fetcher
def initialize(mgr, queues)
@mgr = mgr
@queues = queues.map { |q| "queue:#{q}" }
- @num_queues = queues.uniq.size
+ @unique_queues = @queues.uniq
end
# Fetching is straightforward: the Manager makes a fetch
@@ -49,9 +49,9 @@ def fetch
# recreate the queue command each time we invoke Redis#blpop
# to honor weights and avoid queue starvation.
def queues_cmd
- cmd = @queues.sample(@num_queues)
- cmd << TIMEOUT
- cmd
+ queues = @queues.sample(@unique_queues.size).uniq
+ queues.concat(@unique_queues - queues)
+ queues << TIMEOUT
end
end
end

0 comments on commit bceacec

Please sign in to comment.