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

Eden Li eden at mojiti.com
Thu Apr 26 22:21:52 EDT 2007


(resending to include list, sorry for the double email Geoff)

This was the workaround I ended up using in my app.  Maybe this check
should be done in #worker before it tries to evaluate #object on nil?

Looks like there's a ticket covering this:
 http://backgroundrb.devjavu.com/projects/backgroundrb/ticket/47

On 4/27/07, Geoff Garside <ruby at geoffgarside.co.uk> wrote:
> 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
>
>         MiddleMan.jobs.has_key?(:my_worker_key)
>
> Geoff
> _______________________________________________
> Backgroundrb-devel mailing list
> Backgroundrb-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/backgroundrb-devel
>


More information about the Backgroundrb-devel mailing list