<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Hi<br><br>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. <br>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. <br><br>To explain it further, here is the dummy code<br><br>class MyReactor(threading.Thread):<br>
def __init__(self):<br>
threading.Thread.__init__(self)<br>
def run(self):<br>
reactor.run(installSignalHandlers=0)<br>
<br>
class MyFactory(ClientFactory):<br>
def __init__(self):<br>
self.msg = None<br>
<br>
def setMsg(self, msg):<br>
self.msg = msg<br>
<br>
def connectionFailed(self, connector, reason):<br>
#here i need to send the exception back to the user <br>
<br>class Plugin:<br> def __init__(self):<br> self.running = False<br><br> def send(self, msg):<br> reactor.callFromThread(self.clientsend, msg)<br> def clientsend(self, msg):<br> myfactory = MyFactory()<br> myfactory.setMsg(msg)<br> reactor.connectTCP ('localhost',9999)<br> if( not
self.running):<br> mr = MyReactor()<br>
mr.start()<br> self.running = True<br><br> def startServer(self):<br> reactor.listenTCP(9999,ServerFactory())<br> if( not self.running):<br> mr = MyReactor()<br> mr.start()<br> self.running = True <br><br>class PluginTest:<br> def __init__(self):<br> self.plugin = Plugin()
<br> def start(self):<br> self.plugin.startServer()<br> def send(self,msg):<br> try:<br> self.plugin.send(msg)<br> except:<br> #I want to print send error here<br> # error could be connection fail<br><br>ptest = PluginTest()<br>#I m not starting the server so that I could get the connectionfail
error<br>ptest.send('hi')<br><br>Can you suggest me any work around to get the exception in the PluginUser.send method<br></td></tr></table><br>