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

Brandon Keepers brandon at opensoul.org
Thu Apr 26 15:46:26 EDT 2007

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/ 
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?

What do you think?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 186 bytes
Desc: This is a digitally signed message part
Url : http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20070426/862fca55/attachment.bin 

More information about the Backgroundrb-devel mailing list