Skip to content

Instantly share code, notes, and snippets.

@fclement21
Last active May 9, 2017 14:50
Show Gist options
  • Save fclement21/acfa92cf98b5b8cf2531aeb01fc6912c to your computer and use it in GitHub Desktop.
Save fclement21/acfa92cf98b5b8cf2531aeb01fc6912c to your computer and use it in GitHub Desktop.
Hi, I have a problem with Sidekiq 5.0, I have created 2 different queues (a, b) each corresponds to a Worker (aWorker, bWorker). But when I run for example: aWorker.perform_async (1) bWorker.perform_async (2) aWorker.perfor_async (3) I'll have all the workers who are going to launch at the same time and the second aWorker will not wait until the…
class aWorker
include Sidekiq::Worker
sidekiq_options queue: :a,
run_lock_expiration: 2 * 60,
retry: 3
def perform(object_id)
for timeout in 0..10
puts "HERE AWorker #{object_id}"
sleep(1)
end
end
end
class bWorker
include Sidekiq::Worker
sidekiq_options queue: :b,
run_lock_expiration: 2 * 60,
retry: 3
def perform(object_id)
for timeout in 0..10
puts "HERE BWorker #{object_id}"
sleep(1)
end
end
end
# Command :
#aWorker.perform_async(1)
#bWorker.perform_async(2)
#aWorker.perform_async(3)
2017-05-09T14:37:22.117Z 23014 TID-11b4bc aWorker JID-2088afa552282bd0a6894d7b INFO: start
2017-05-09T14:37:24.123Z 23014 TID-11b638 bWorker JID-bc751df81c388ae4437b70d8 INFO: start
2017-05-09T14:37:26.131Z 23014 TID-11b4rg aWorker JID-6c7af539aad808f57143a3a0 INFO: start
2017-05-09T14:37:33.121Z 23014 TID-11b4bc aWorker JID-2088afa552282bd0a6894d7b INFO: done: 11.004 sec
2017-05-09T14:37:35.128Z 23014 TID-11b638 bWorker JID-bc751df81c388ae4437b70d8 INFO: done: 11.005 sec
2017-05-09T14:37:37.136Z 23014 TID-11b4rg aWorker JID-6c7af539aad808f57143a3a0 INFO: done: 11.005 sec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment