[Twisted-Python] how to pass on the connection failed or connection lost error

Jean-Paul Calderone exarkun at divmod.com
Wed Mar 4 09:59:42 EST 2009

On Wed, 4 Mar 2009 06:39:59 -0800 (PST), khawar hasham <hasham_james_007 at yahoo.com> wrote:
>let me first explain the application that I am developing. I have an application that will use the twisted part as a plugin. this twisted part will act as server and as client both.
>my application call the plugin method to send data to server module using connectTCP. now the problem is I can not pass on the connection failed exception to my calling application.

Since you're running the reactor in one thread and the rest of your
application in another thread, your question is basically one of message
passing.  You've already found reactor.callFromThread which is good; I
think you just want the slightly more featureful version, available in
twisted.internet.threads, blockingCallFromThread.  This is implemented
in terms of callFromThread, but additionally allows the caller to get
the result of the function being called - including waiting on a Deferred
if the function being called returns one.  If you switch to this, then
you only need to make Plugin.clientsend return a Deferred which eventually
fires with a result or a Failure.


More information about the Twisted-Python mailing list