[Twisted-Python] Correct way to handle errors of connectTCP
Hi, I expected reactor.connectTCP to return a deferred. That would have been nice, since callbacks would have handled the outcome. So how to I handle failure with it? I tried: from twisted.internet.error import ConnectionRefusedError print "Connecting..." try: reactor.connectTCP(self.server, self.port, self.f) except ConnectionRefusedError(reason): self.Connect_Failure() return self.Connect_Success() No good. What am I missing? Thank you! Simon -- Linux user #458601 - http://counter.li.org.
On Mon, 31 Mar 2008 19:59:46 +0100, Simon Pickles <sipickles@hotmail.com> wrote:
Hi,
I expected reactor.connectTCP to return a deferred. That would have been nice, since callbacks would have handled the outcome.
So how to I handle failure with it?
ClientFactory.clientConnectionFailed will be called if the connection attempt fails for some reason. Jean-Paul
Jean-Paul Calderone wrote:
On Mon, 31 Mar 2008 19:59:46 +0100, Simon Pickles <sipickles@hotmail.com> wrote:
Hi,
I expected reactor.connectTCP to return a deferred. That would have been nice, since callbacks would have handled the outcome.
So how to I handle failure with it?
ClientFactory.clientConnectionFailed will be called if the connection attempt fails for some reason.
Jean-Paul Doh! :)
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
-- Linux Counter: User# 424693
participants (2)
-
Jean-Paul Calderone
-
Simon Pickles