util: deferredutil: undo my recent patch to use our own implementation of gatherResults

It seems to cause lots of failures on some builders.
This commit is contained in:
Zooko O'Whielacronx 2009-01-07 11:00:05 -07:00
parent 79535e4f5b
commit 2122ba78b3
1 changed files with 11 additions and 21 deletions

View File

@ -21,25 +21,15 @@ def _unwrapFirstError(f):
f.trap(defer.FirstError) f.trap(defer.FirstError)
raise f.value.subFailure raise f.value.subFailure
class ResultsGatherer: def gatherResults(deferredList):
def __init__(self, deferredlist): """Returns list with result of given Deferreds.
self.deferredlist = deferredlist
self.fired = 0 This builds on C{DeferredList} but is useful since you don't
self.results = [] need to parse the result for success/failure.
self.d = defer.Deferred()
for d in deferredlist: @type deferredList: C{list} of L{Deferred}s
d.addCallbacks(self._cb, self._eb) """
def start(self): d = defer.DeferredList(deferredList, fireOnOneErrback=True, consumeErrors=True)
return self.d d.addCallbacks(_parseDListResult, _unwrapFirstError)
def _cb(self, res): return d
self.results.append(res)
self.fired += 1
if self.fired >= len(self.deferredlist):
self.d.callback(self.results)
def _eb(self, f):
self.d.errback(f)
def gatherResults(deferredlist):
""" Return a deferred that fires with a list of the results of the deferreds, or else errbacks with any error. """
r = ResultsGatherer(deferredlist)
return r.start()