[Twisted-Python] Dealing with an intermittent PB server

Jp Calderone exarkun at divmod.com
Thu Feb 17 18:34:30 EST 2005

On Thu, 17 Feb 2005 11:31:24 -0800, Dave Cook <daverz at gmail.com> wrote:
>On Thu, 17 Feb 2005 01:05:22 +0000, Phil Mayers <p.mayers at imperial.ac.uk> wrote:
> >     try:
> >       self.root.callRemote('start').addCallbacks(self.start2, self.err)
> I never get this far.  In my code:
>     def data_tableList(self, ctx, data):
>         ...
>         d = self.pbClientFactory.login(creds).addCallbacks(self._cbLogin,
> self._ebLogin)
>         return d

  Are you totally certain _cbLogin is never called?  Remember, _ebLogin 
_will not_ be used as the errback for _cbLogin when it is added in the 
above manner: it will only handle errors from the .login() Deferred.  To
have _ebLogin handle all errors (except for those from itself):

       def data_tableList(self, ctx, data):
           d = self.pbClientFactory.login(creds)
           return d

  Or, to have _ebLogin continue handling errors from .login() and to have 
a separate error handler for _cbLogin and _ebLogin():

       def data_tableList(self, ctx, data):
           d = self.pbClientFactory.login(creds)
           d.addCallbacks(self._cbLogin, self._ebLogin)
           return d

  twisted.python.log.err is a really handy thing to use in place of
self._ebCallbacks while debugging.  It can very quickly show you an 
error you didn't even realize was happening (often a silly one - like
declaring the wrong number of arguments to a callback function, causing 
a TypeError when Twisted tries to call it, making it appear as though 
the function is never called at all).


More information about the Twisted-Python mailing list