1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

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

This commit is contained in:
Ryan LeCompte 2012-04-03 23:35:46 -07:00
parent e65c6fcd3d
commit bceacec766

View file

@ -16,7 +16,7 @@ module Sidekiq
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 @@ module Sidekiq
# 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