[Twisted-Python] Passing additional arguments to errback

Maciej Wasilak wasilak at gmail.com
Wed Sep 4 06:04:26 MDT 2013


Dear list,

I've found such a code example on "Stack Overflow" regarding errbacks:
___________________________

class YourExample(object):
    def your_example(self):
        self.agent = Agent(reactor, pool=pool)
        self.deferred = self.agent.request(
                'GET',
                self.url,
                Headers({'User-Agent': ['Mozilla/5.0']})
            )

        self.deferred.addCallback(self.gotResponse).addErrback(self.gotBadResponse)
def gotBadResponse(self,raised):
    """you might have cleanup code here, or mark the url as bad in the
database, or something similar"""
    pass
__________________________

Normally only Failure object is passed to gotBadResponse() . I would
like to pass full response body to it - is it possible?
Do I have to encapsulate the response body inside Failure object?

Best regards

Maciek
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://twistedmatrix.com/pipermail/twisted-python/attachments/20130904/e5858072/attachment.html>


More information about the Twisted-Python mailing list