[Twisted-web] Class methods as callbacks/errbacks

A Desai ardesai at yahoo.com
Sun Jun 5 19:44:50 EDT 2011


Thank you for the responses.  Specifying the bound instance method as the callback works.  (I remember it did not work for me many months ago, hence my post).  Works now.

Thanks,
-Arun

--- On Sat, 6/4/11, A Desai <ardesai at yahoo.com> wrote:

From: A Desai <ardesai at yahoo.com>
Subject: Class methods as callbacks/errbacks
To: twisted-web at twistedmatrix.com
Date: Saturday, June 4, 2011, 9:31 PM

I use a wrapper functions as follows to specify the callback argument of addCallback() and addErrback().

def reqConnLostCallbk(result, arg_self):
    arg_self.lost_conn()

def reqConnLostErrbk(failure, arg_self):
    arg_self.lost_conn()


... inside a class method
    d.addCallback(reqConnLostCallbk, self)
    d.addErrback(reqConnLostErrbk, self)

    def lost_conn(self):
        // cleanup
        pass

Is there an alternative and/or cleaner solution to specify a class method as a callback or errback?

-Arun
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-web/attachments/20110605/8909c418/attachment.htm 


More information about the Twisted-web mailing list