BackgrounDRb question

Hi,

I am going to use BackgrounDRb for to handle some processing, but have one question that I haven't been able to find in the documentation. I have an application that accepts XML docs via a HTTP POST. I am going to hand the processing of the XML doc to worker, so that I can send back a HTTP REPLY right away. It seems that you need to make an explicit call to worker.delete to stop it from running. My question is, is there an easy way for the worker to delete itself after running its do_work method, or a way to notify the main application that it has completed the processing and is ready to be deleted?

Thanks,

Simon

Hi Simon,

Simon wrote:

is, is there an easy way for the worker to delete itself after running its do_work method, or a way to notify the main application that it has completed the processing and is ready to be deleted?

Add the following two lines at the bottom of your do_work method.

ActiveRecord::Base.connection.disconnect! ::BackgrounDRb::MiddleMan.instance.delete_worker @_job_key

The first ensures that the database connection has been closed and the second kills the worker.

hth, Bill

Hi,

I tried adding those two lines to the bottom of my do_work method, and am now getting the following error on the second line (::BackgrounDRb::MiddleMan.instance.delete_worker @_job_key)

20070405-13:15:15 (19653) In do work 20070405-13:15:18 (19653) You have a nil object when you didn't expect it! The error occured while evaluating nil.shutdown - (NoMethodError) 20070405-13:15:18 (19653) /usr/local/src/rails/434Wireless/vendor/ plugins/backgroundrb/server/lib/backgroundrb/middleman.rb:373:in `delete_worker' 20070405-13:15:18 (19653) /usr/local/src/rails/434Wireless/lib/workers/ parser_worker.rb:657:in `do_work'

Any ideas what the issue might be?

Thanks again,

Simon

Yes, it does. What I'm trying to do is to delete the worker from inside its own do_work method, so that the main Rails app creates a new worker instance, and then the worker does some work, and deletes itself. Is there another method to accomplish this?

Thanks,

Simon