Hi,
I''m using backgroundrb but I have 2 problems with it.
First is when I launch a thread Toto from the do_work method. Toto
can''t
access to a class variable defined before... (undefined method `+'' for
nil:NilClass)
I suspect that thread is launched when backgroundrb start but the worker not
..
My code is :
class MonWorker < BackgrounDRb::Worker::RailsBase
attr_reader :mavar_send, :mavar_receive
@@mavar_send, @@mavar_receive = 0
def do_work(args)
trace = Thread.new{t_trace}
trace.join
end
def t_trace
while true
@@mavar_send += 1
sleep 1
end
end
Second is I''m trying to call a worker from another to send it an
object, is
it possible ?
job =MiddleMan.worker(:second_worker) doesn''t work in my first worker.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20070621/9ef42cbe/attachment.html
2007/6/21, Fr?d?ric Logier :> > > Second is I''m trying to call a worker from another to send it an object, > is it possible ? > job =MiddleMan.worker(:second_worker) doesn''t work in my first worker.I see this bug report : http://backgroundrb.devjavu.com/projects/backgroundrb/ticket/55 but I don''t understand this : "I can pass the actual worker reference into the other workers in args and that works" I tried this but it doesn''t work better, second worker crash : s_worker = MiddleMan.new_worker(:class => :FIRSTWorker, :job_key => :first_worker, :args => "") MiddleMan.new_worker(:class => :SECONDWorker, :job_key => :second_worker, :args => {:sms_job_key => s_worker}) def do_work(args) @sms_worker = args[:sms_job_key] end def test @sms_worker.test("hello") end -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20070621/767d6bc5/attachment.html
2007/6/21, Fr?d?ric Logier :> > > I tried this but it doesn''t work better, second worker crash : > > > s_worker = MiddleMan.new_worker(:class => :FIRSTWorker, > :job_key => :first_worker, > :args => "") > > MiddleMan.new_worker(:class => :SECONDWorker, > :job_key => :second_worker, > :args => {:sms_job_key => s_worker}) >works better with s_worker = MiddleMan.worker(:sms_worker) before ! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20070621/0bfcda0e/attachment.html