Package buildbot :: Package monkeypatches :: Module bug4520
[frames] | no frames]

Source Code for Module buildbot.monkeypatches.bug4520

 1  # coding=utf-8 
 2  # This file is part of Buildbot.  Buildbot is free software: you can 
 3  # redistribute it and/or modify it under the terms of the GNU General Public 
 4  # License as published by the Free Software Foundation, version 2. 
 5  # 
 6  # This program is distributed in the hope that it will be useful, but WITHOUT 
 7  # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
 8  # FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more 
 9  # details. 
10  # 
11  # You should have received a copy of the GNU General Public License along with 
12  # this program; if not, write to the Free Software Foundation, Inc., 51 
13  # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 
14  # 
15  # Copyright Buildbot Team Members 
16   
17  from twisted.spread import pb 
18  from twisted.python import log 
19   
20 -def patch():
21 log.msg("Applying patch for http://twistedmatrix.com/trac/ticket/4520") 22 pb.RemoteError = RemoteError 23 pb.CopiedFailure.throwExceptionIntoGenerator = \ 24 CopiedFailure_throwExceptionIntoGenerator 25 old_getStateToCopy = pb.CopyableFailure.getStateToCopy 26 def getStateToCopy(self): 27 state = old_getStateToCopy(self) 28 state['value'] = str(self.value) # Exception instance 29 return state
30 31 32 ############################################################################# 33 # Everything below this line was taken from Twisted, except as annotated. See 34 # http://twistedmatrix.com/trac/changeset/32211 35 # 36 # Merge copiedfailure-stringexc-4520 37 # 38 # Author: sirgolan, Koblaid, glyph 39 # Reviewer: exarkun, glyph 40 # Fixes: #4520 41 # 42 # Allow inlineCallbacks and exceptions raised from a twisted.spread remote 43 # call to work together. A new RemoteError exception will be raised into 44 # the generator when a yielded Deferred fails with a remote PB failure. 45
46 -class RemoteError(Exception):
47 - def __init__(self, remoteType, value, remoteTraceback):
48 Exception.__init__(self, value) 49 self.remoteType = remoteType 50 self.remoteTraceback = remoteTraceback
51
52 -def CopiedFailure_throwExceptionIntoGenerator(self, g):
53 return g.throw(RemoteError(self.type, self.value, self.traceback))
54