[Backgroundrb-devel] MY worker won't stop working

Chris H chris at etechdata.com.au
Tue Jul 25 02:25:00 EDT 2006

Hi Ezra,

love backgroundrb! Awesome plugin!

I have a worker that processes some data files and loads this data in mysql.
It runs fine and processes all the files. 

However if I try to call delete_worker from my controller while it is 
processing ,
it says it has stopped the worker but I can still see the process
in top and also see the rows still going into mysql.

My do_work looks like this:

  def do_work(args)
    # This method is called in it's own new thread when you
    # call new worker. args is set to :args
    if args
      @process_cdr = ProcessCdr.new(args)
      @process_cdr = ProcessCdr.new


I have start and stop actions in my controller:

 def start
    if @params[:cdr_file].to_s.length > 0
      MiddleMan[:process_watcher] ||MiddleMan.new_worker(:class => 
:watch_cdr_process_worker, :args => @params[:cdr_file].to_s, :job_key => 
      MiddleMan[:process_watcher] || MiddleMan.new_worker(:class => 
:watch_cdr_process_worker, :job_key => :process_watcher)
    redirect_to :action => 'status'
  def stop
    MiddleMan.delete_worker(:process_watcher) if MiddleMan[:process_watcher]
    redirect_to :action => 'status'

I have some ajax code monitoring the status of my worker and when I 
choose stop it responds that my worker has indeed stopped.

I also tried adding a method stop_work to my worker which called 
self.terminate but this didn't seem to work either.

I'm confused as to what I should be doing to get my worker to stop.

Thanks in advance,

More information about the Backgroundrb-devel mailing list