brandonhilkert / sucker_punch

Sucker Punch is a Ruby asynchronous processing library using concurrent-ruby, heavily influenced by Sidekiq and girl_friday.
MIT License
2.65k stars 114 forks source link

"Couldnt cleanly terminate all actors in 10 seconds" - Rails Rake issue #62

Closed stevepm closed 10 years ago

stevepm commented 10 years ago

Hi,

I'm having trouble running a rake task that calls a sucker punch job:

I'm testing to see if it works in the production environment, as it wasn't working in the development environment either. Rake Task: RAILS_ENV=production DATABASE_URL=postgres://localhost/popular_gems_development rake gem:update_all

Output: Starting - Starting 80legs Updating data for -..... Updating data for 80legs..... Ending - Ending 80legs Couldn't cleanly terminate all actors in 10 seconds!

The code in the rake task:

PopularGem.all.each do |gem|
      UpdateGemJob.new.async.perform(gem)
    end

If I run that same code in the rails console, it works fine, going through each gem in my database and updating each of them.

The code in the job:

class UpdateGemJob
  include SuckerPunch::Job

  def perform(gem)
    puts "Starting #{gem.name}\n"
    ActiveRecord::Base.connection_pool.with_connection do
      ::PopularGem.without_timestamps do
        ::GemImporter.update_gem(gem.name)
      end
    end
    puts "Ending #{gem.name}\n"
  end
end
stevepm commented 10 years ago

After reading an earlier issue with similar problems(https://github.com/brandonhilkert/sucker_punch/issues/44), I added sleep 1 to my rake file after I queue the job and it seems to be working...

brandonhilkert commented 10 years ago

Glad to hear you got it working!