Sidekiq: perform_async does nothing in Rake task

Created on 13 Mar 2017  路  6Comments  路  Source: mperham/sidekiq

Ruby version: 2.3.3
Sidekiq version(s): 4.2.2
Rails 4.2.7

If relevant, please include your initializer and any error message with the full backtrace.

no error messages.

when trying to start a sidekiq job from a Rake task, nothing happens.

require 'sidekiq/api'

namespace :db do
  task migrate_rewiews_to_scoring_periods: [:environment] do


    MyModel.find_each do |this|
      MyWorker.perform_async( this.id )
    end
end
end

Most helpful comment

I can't believe I guessed correctly.

wow

All 6 comments

You are requiring 'sidekiq/testing' or rspec-sidekiq somewhere so your jobs are going into a local array for test assertion, not into Redis.

this is not for testing ... i'm trying to create Sidekiq jobs from a Rake task..
and the workers are not picking it up.

Looks like the Sidekiq client config is not done correctly for rake tasks?

How can I fix this?

I did not say it was for testing. I said you are requiring it anyhow, probably in your Gemfile. Read the IMPORTANT note here:

https://github.com/philostler/rspec-sidekiq#installation

Thank you, Mike! You are definitely psychic! :)
Somebody required 'sidekiq/testing' in another rake task - it beats me why they would do such a thing.

I guess that's what you get when you inherit a messy code base :-/

I can't believe I guessed correctly.

wow

well, you must have gotten that question a gazillion times! :-D

Was this page helpful?
0 / 5 - 0 ratings