I'm working with delayed_job for the first time, and have run up a trivial test application to play with. But the worker isn't running the jobs properly and I don't know what to make of these errors.
This is the model I'm trying:
class NumberAdder
def add_two(a, b)
result = a + b
Rails.logger.debug "#{a} + #{b} = #{result}"
end
end
And here's what I get when I try to actually run a queued job:
# This looks OK
>> NumberAdder.new.send_later :add_two, 3, 4
=> #<Delayed::Backend::ActiveRecord::Job id: 6, priority: 0, attempts: 0, handler: "--- !ruby/struct:Delayed::PerformableMethod \nobject...", last_error: nil, run_at: "2010-04-02 22:01:46", locked_at: nil, failed_at: nil, locked_by: nil, created_at: "2010-04-02 22:01:46", updated_at: "2010-04-02 22:01:46">
# But then...
phil@beast:~/src/test/delayed_job_test$ rake jobs:work
(in /home/phil/src/test/delayed_job_test)
*** Starting job worker host:beast pid:11824
* [Worker(host:beast pid:11824)] acquired lock on NumberAdder#add_two
* [JOB] host:beast pid:11824 failed with NoMethodError: undefined method `add_two' for #<YAML::Object:0xb76593b8 @ivars={}, @class="NumberAdder"> - 0 failed attempts
* [Worker(host:beast pid:11824)] acquired lock on NumberAdder#add_two
* [JOB] host:beast pid:11824 failed with NoMethodError: undefined method `add_two' for #<YAML::Object:0xb7631bc4 @ivars={}, @class="NumberAdder"> - 1 failed attempts
2 jobs processed at 17.3046 j/s, 2 failed ...
Any advice would be most appreciated.
--Phil
dan croak
thoughtbot
> --
> You received this message because you are subscribed to the Boston
> Ruby Group mailing list
> To post to this group, send email to boston-r...@googlegroups.com
> To unsubscribe from this group, send email to boston-rubygro...@googlegroups.com
> For more options, visit this group at http://groups.google.com/group/boston-rubygroup
>
> To unsubscribe, reply using "remove me" as the subject.
>> NumberAdder
>> Delayed::Job.work_off
That'll get you on the right path.
- Blake
Thanks all! Putting a "require 'number_adder'" in environment.rb did the trick. Now to go try this in some non-toy code... --Phil --- On Fri, 4/2/10, Ryan Angilly <ry...@angilly.com> wrote: |