[Backgroundrb-devel] Canceling work...

Yves-Eric Martin yem_backgroundrb-devel at filter.yve.net
Wed Feb 20 18:36:38 EST 2008


Hi all,


Just and idea:

The normal way of doing cleanup in Ruby is to use a "begin...ensure" 
construct.
Maybe that will work here too? Try something like this:


class FooWorker < BackgrounDRb::MetaWorker
  def some_work(args=nil)
    begin
      # Large batch job here
      ...
    rescue # (optional)
      # Error processing here
      ...
    ensure
      # Cleanup code here
      ...
    end
  end
end


Then, just invoke delete_worker when you need to, and if all is well, it 
should interrupt the running batch job, but your cleanup code *should* 
get executed before the worker finally dies. If it is not, I'd call it a 
BackgrounDRb bug, as it would be breaking some basic Ruby functionality.

Let us know how it goes.


Cheers,

-- 
Yves-Eric Martin

John Wells wrote:
>
>     class FooWorker < BackgrounDRb::MetaWorker
>        def some_work(args = nil)
>           # do some job processing from database
>           exit
>         end
>     end
>
>
>
> Ok, but when would exit be called here? After all the work is done?
>
> I guess what I want is a kill -9 functionality, but with the ability 
> to at the very least clear the worker's status...
> ------------------------------------------------------------------------
>
> _______________________________________________
> Backgroundrb-devel mailing list
> Backgroundrb-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/backgroundrb-devel



More information about the Backgroundrb-devel mailing list