[Backgroundrb-devel] looking for a worker that's gone

Geoff Garside ruby at geoffgarside.co.uk
Thu Apr 26 17:00:28 EDT 2007

On 26 Apr 2007, at 20:46, Brandon Keepers wrote:

> In my app, I store the job key when a worker is fired off and then  
> check back in periodically to see how its doing.  The workers  
> delete themselves when they're done.  I would expect when I try to  
> get  a worker that has been deleted, I would get nil or a proper  
> exception, but instead I get:
>  >> MiddleMan.worker('foobar')
> NoMethodError: undefined method `object' for nil:NilClass
>         from (drbunix:///tmp/backgroundrbunix_localhost_2000) / 
> Users/brandon/projects/backgroundrb/vendor/plugins/backgroundrb/ 
> server/lib/backgroundrb/middleman.rb:396:in `worker'
> I've modified MiddleMan#worker to return nil if the job doesn't exist:
>     def worker(key)
>       worker = ex { @jobs[key].object if @jobs[key] }
>       WorkerProxy.new(worker) unless worker.nil?
>     end
> What do you think?
> Brandon
> _______________________________________________
> Backgroundrb-devel mailing list
> Backgroundrb-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/backgroundrb-devel

Certainly seems like a good idea to me.

It is a little messy to be testing for a NoMethodError when checking  
to see if a worker is still alive. At the same time though you can  
currently do



More information about the Backgroundrb-devel mailing list