[Twisted-Python] FirstError handling from defer.gatherResults()?

Justin Warren daedalus at eigenmagic.com
Tue Nov 4 19:58:41 EST 2008

I'm missing something obvious, so I must consult the gurus of the list:

I have some code that gets info from remote devices, a little like this:

def get_thing_info():
  dlist = []
  for thing in thinglist:
    d = thing.fetch_info()

  return defer.gatherResults(dlist)

If an error occurs, gatherResults() behaves like
DeferredList(fireOnOneErrback=True), but the errback will receive a
FirstError object, not a Failure.

Normally, I'd do something like this in an Errback:

def cb_handle_failure(failure):
  e = failure.trap(MyNonFatalException)
  if e:
    log.debug("Not a fatal failure. Getting info again.")
    return get_thing_info()

But what is the right way to do this when I receive a FirstError?

Justin Warren <daedalus at eigenmagic.com>

More information about the Twisted-Python mailing list