<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Hi,<br><br>I tried to use this suggestion but I could not make it work.<br><br>here is the test I am using<br><br>in my application class<br>def callSend(self, msg):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; plugin.send(msg)<br><br>Now in plugin class<br>def send(self, msg):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print 'before call'<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; threads.blockingCallFromThread(reactor, remotesend, msg)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print 'after call'<br><br>def handleError(self, error):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; error.raiseException()<br><br>def remotesend(self, msg):<br>&nbsp;&nbsp;&nbsp;&nbsp; deferred = defer.Deferred()<br>&nbsp;&nbsp;&nbsp;&nbsp; reactor.connectTCP('localhost',9999,myfactory)<br>&nbsp;&nbsp;&nbsp;&nbsp; deffered.addErrback(self.handleError)<br>&nbsp;&nbsp;&nbsp;&nbsp; return deffered<br><br>now myfactory class ..
 clientConnectionFailed <br>def clientConnectionFailed(self, connector, reason):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; reason.raiseException()<br><br><br>now the problem is, code has become synchronous as code is waiting after threads.blockingCallFromThread, how to fire the defer returned from 'remotesend'. Do i need to fire it or twisted will take care of it.<br><br>I think I can't refer this deferred object since it is being passed to threads.blockingCallFromThread function on which I have no control.<br><br>any suggestions<br><br><br>--- On <b>Wed, 3/4/09, twisted-python-request@twistedmatrix.com <i>&lt;twisted-python-request@twistedmatrix.com&gt;</i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;">From: twisted-python-request@twistedmatrix.com &lt;twisted-python-request@twistedmatrix.com&gt;<br>Subject: Twisted-Python Digest, Vol 60, Issue 6<br>To: twisted-python@twistedmatrix.com<br>Date:
 Wednesday, March 4, 2009, 11:00 AM<br><br><pre>Send Twisted-Python mailing list submissions to<br>        twisted-python@twistedmatrix.com<br><br>To subscribe or unsubscribe via the World Wide Web, visit<br>        http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python<br>or, via email, send a message with subject or body 'help' to<br>        twisted-python-request@twistedmatrix.com<br><br>You can reach the person managing the list at<br>        twisted-python-owner@twistedmatrix.com<br><br>When replying, please edit your Subject line so it is more specific<br>than "Re: Contents of Twisted-Python digest..."<br><br><br>Today's Topics:<br><br>   1. Re: how to pass on the connection failed or        connection lost<br>      error (Jean-Paul Calderone)<br><br><br>----------------------------------------------------------------------<br><br>Message: 1<br>Date: Wed, 4 Mar 2009 09:59:42 -0500<br>From: Jean-Paul Calderone &lt;exarkun@divmod.com&gt;<br>Subject: Re: [Twisted-Python] how
 to pass on the connection failed or<br>        connection lost error<br>To: twisted-python@twistedmatrix.com<br>Message-ID:<br>        &lt;20090304145942.12853.42253504.divmod.quotient.17917@henry.divmod.com&gt;<br>Content-Type: text/plain; format=flowed<br><br>On Wed, 4 Mar 2009 06:39:59 -0800 (PST), khawar hasham<br>&lt;hasham_james_007@yahoo.com&gt; wrote:<br>&gt;Hi<br>&gt;<br>&gt;let me first explain the application that I am developing. I have an<br>application that will use the twisted part as a plugin. this twisted part will<br>act as server and as client both.<br>&gt;my application call the plugin method to send data to server module using<br>connectTCP. now the problem is I can not pass on the connection failed exception<br>to my calling application.<br><br>Since you're running the reactor in one thread and the rest of your<br>application in another thread, your question is basically one of message<br>passing.  You've already found reactor.callFromThread
 which is good; I<br>think you just want the slightly more featureful version, available in<br>twisted.internet.threads, blockingCallFromThread.  This is implemented<br>in terms of callFromThread, but additionally allows the caller to get<br>the result of the function being called - including waiting on a Deferred<br>if the function being called returns one.  If you switch to this, then<br>you only need to make Plugin.clientsend return a Deferred which eventually<br>fires with a result or a Failure.<br><br>Jean-Paul<br><br><br><br>------------------------------<br><br>_______________________________________________<br>Twisted-Python mailing list<br>Twisted-Python@twistedmatrix.com<br>http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python<br><br><br>End of Twisted-Python Digest, Vol 60, Issue 6<br>*********************************************<br></pre></blockquote></td></tr></table><br>