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

Is it impossible to use SP just from ruby? #131

Closed gazay closed 8 years ago

gazay commented 8 years ago

Hello, I've tried this:

require 'sucker_punch'

class AJob
  include SuckerPunch::Job

  def perform
    puts 1
  end
end

AJob.new.async.perform

And I've recieved following error:

$ ruby simple.rb
D, [2015-10-08T19:44:54.233826 #3212] DEBUG -- : Terminating 3 actors...
W, [2015-10-08T19:44:54.234263 #3212]  WARN -- : Terminating task: type=:finalizer, meta={:method_name=>:__shutdown__}, status=:receiving
    Celluloid::TaskFiber backtrace unavailable. Please try `Celluloid.task_class = Celluloid::TaskThread` if you need backtraces here.

With Celluloid.task_class = Celluloid::TaskThread:

$ ruby simple.rb
D, [2015-10-08T19:46:41.888957 #3319] DEBUG -- : Terminating 3 actors...
brandonhilkert commented 8 years ago

The script is exiting and killing the actors off before it does it's work. Add sleep 1 after the invocation and it'll work.

gazay commented 8 years ago

Thanks!