Skip to content

Commit

Permalink
Merge branch 'gatherResults'
Browse files Browse the repository at this point in the history
  • Loading branch information
tomprince committed Jan 20, 2013
2 parents 7ba03c1 + 3d54fef commit 56e9259
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
7 changes: 7 additions & 0 deletions master/buildbot/monkeypatches/__init__.py
Expand Up @@ -62,12 +62,19 @@ def patch_sqlalchemy2189():
from buildbot.monkeypatches import sqlalchemy2189
sqlalchemy2189.patch()

def patch_gatherResults():
if twisted.version < versions.Version('twisted', 11, 1, 0):
from buildbot.monkeypatches import gatherResults
gatherResults.patch()


def patch_all(for_tests=False):
patch_bug4881()
patch_bug4520()
patch_bug5079()
patch_sqlalchemy2364()
patch_sqlalchemy2189()
patch_gatherResults()

if for_tests:
from buildbot.monkeypatches import servicechecks
Expand Down
71 changes: 71 additions & 0 deletions master/buildbot/monkeypatches/gatherResults.py
@@ -0,0 +1,71 @@
# This file is part of Buildbot. Buildbot is free software: you can
# redistribute it and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright Buildbot Team Members

from twisted.internet import defer

def patch():
"""
Patch gatherResults to support consumeErrors on old versions of twisted
"""
defer.gatherResults = gatherResults

#############################################################################
# Everything below this line was taken from Twisted, except as annotated. See
# https://twistedmatrix.com/trac/browser/trunk/twisted/internet/defer.py?rev=32405#L805
#
# Merge gatherresults-consumeerrors-5159
#
# Author: dustin
# Reviewer: exarkun
# Fixes: #5159
#
# Add a `consumeErrors` parameter to `twisted.internet.defer.gatherResults`
# with the same meaning as the parameter of the same name accepted by
# `DeferredList`.



def _parseDListResult(l, fireOnOneErrback=False):
if __debug__:
for success, value in l:
assert success
return [x[1] for x in l]

def gatherResults(deferredList, consumeErrors=False):
"""
Returns, via a L{Deferred}, a list with the results of the given
L{Deferred}s - in effect, a "join" of multiple deferred operations.
The returned L{Deferred} will fire when I{all} of the provided L{Deferred}s
have fired, or when any one of them has failed.
This differs from L{DeferredList} in that you don't need to parse
the result for success/failure.
@type deferredList: C{list} of L{Deferred}s
@param consumeErrors: (keyword param) a flag, defaulting to False,
indicating that failures in any of the given L{Deferreds} should not be
propagated to errbacks added to the individual L{Deferreds} after this
L{gatherResults} invocation. Any such errors in the individual
L{Deferred}s will be converted to a callback result of C{None}. This
is useful to prevent spurious 'Unhandled error in Deferred' messages
from being logged. This parameter is available since 11.1.0.
@type consumeErrors: C{bool}
"""
d = defer.DeferredList(deferredList, fireOnOneErrback=True,
consumeErrors=consumeErrors)
d.addCallback(_parseDListResult)
return d

0 comments on commit 56e9259

Please sign in to comment.