Hi,
I tried to use this suggestion but I could not make it work.
here is the test I am using
in my application class
def callSend(self, msg):
plugin.send(msg)
Now in plugin class
def send(self, msg):
print 'before call'
threads.blockingCallFromThread(reactor, remotesend, msg)
print 'after call'
def handleError(self, error):
error.raiseException()
def remotesend(self, msg):
deferred = defer.Deferred()
reactor.connectTCP('localhost',9999,myfactory)
deffered.addErrback(self.handleError)
return deffered
now myfactory class .. clientConnectionFailed
def clientConnectionFailed(self, connector, reason):
reason.raiseException()
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.
I think I can't refer this deferred object since it is being passed to
threads.blockingCallFromThread function on which I have no control.
any suggestions
--- On Wed, 3/4/09, [email protected]
<[email protected]> wrote:
From: [email protected]
<[email protected]>
Subject: Twisted-Python Digest, Vol 60, Issue 6
To: [email protected]
Date: Wednesday, March 4, 2009, 11:00 AM
Send Twisted-Python mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Twisted-Python digest..."
Today's Topics:
1. Re: how to pass on the connection failed or connection lost
error (Jean-Paul Calderone)
----------------------------------------------------------------------
Message: 1
Date: Wed, 4 Mar 2009 09:59:42 -0500
From: Jean-Paul Calderone <[email protected]>
Subject: Re: [Twisted-Python] how to pass on the connection failed or
connection lost error
To: [email protected]
Message-ID:
<20090304145942.12853.42253504.divmod.quotient.17...@henry.divmod.com>
Content-Type: text/plain; format=flowed
On Wed, 4 Mar 2009 06:39:59 -0800 (PST), khawar hasham
<[email protected]> wrote:
>Hi
>
>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.
Jean-Paul
------------------------------
_______________________________________________
Twisted-Python mailing list
[email protected]
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
End of Twisted-Python Digest, Vol 60, Issue 6
*********************************************
_______________________________________________
Twisted-Python mailing list
[email protected]
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python