Tomasz Kaye
2007-Jan-23 11:19 UTC
[Backgroundrb-devel] Getting results from a dead worker. example?
I''m having a little difficulty understanding how to retrieve results from deceased workers (from the documentation it seems that it is possible to do this). I pasted my simple test below. If anyone could point out what i should be doing differently i''d be very grateful. My test worker: class TestWorker < BackgrounDRb::Worker::RailsBase def do_work(args) results[:done_with_do_work] = true self.delete end end TestWorker.register My rake task: task :tester => :environment do k=MiddleMan.new_worker( :class => :test_worker ) sleep 1 # the worker will die during this pause # next line gives a nil object error puts "done_with_do_work=#{MiddleMan.worker(k).results [:done_with_do_work]||"not available"}" end
Ezra Zygmuntowicz
2007-Jan-23 19:03 UTC
[Backgroundrb-devel] Getting results from a dead worker. example?
On Jan 23, 2007, at 3:19 AM, Tomasz Kaye wrote:> I''m having a little difficulty understanding how to retrieve results > from deceased workers (from the documentation it seems that it is > possible to do this). > > I pasted my simple test below. If anyone could point out what i > should be doing differently i''d be very grateful. > > My test worker: > > class TestWorker < BackgrounDRb::Worker::RailsBase > def do_work(args) > results[:done_with_do_work] = true > self.delete > end > end > TestWorker.register > > My rake task: > > task :tester => :environment do > k=MiddleMan.new_worker( > :class => :test_worker > ) > sleep 1 # the worker will die during this pause > # next line gives a nil object error > puts "done_with_do_work=#{MiddleMan.worker(k).results > [:done_with_do_work]||"not available"}" > endI am thinking about changing the way we store results. I think it might make a lot more sense to use a database table for results. The Results worker has been problematic. So for now I suggest storing any results you need in a db table and get the results in rails from said table. I hope to have some time soon to work on this but I am pretty busy at the moment. Cheers- -- Ezra Zygmuntowicz -- Lead Rails Evangelist -- ez at engineyard.com -- Engine Yard, Serious Rails Hosting -- (866) 518-YARD (9273)