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.
To explain it further, here is the dummy code
class MyReactor(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
def run(self):
reactor.run(installSignalHandlers=0)
class MyFactory(ClientFactory):
def __init__(self):
self.msg = None
def setMsg(self, msg):
self.msg = msg
def connectionFailed(self, connector, reason):
#here i need to send the exception back to the user
class Plugin:
def __init__(self):
self.running = False
def send(self, msg):
reactor.callFromThread(self.clientsend, msg)
def clientsend(self, msg):
myfactory = MyFactory()
myfactory.setMsg(msg)
reactor.connectTCP ('localhost',9999)
if( not self.running):
mr = MyReactor()
mr.start()
self.running = True
def startServer(self):
reactor.listenTCP(9999,ServerFactory())
if( not self.running):
mr = MyReactor()
mr.start()
self.running = True
class PluginTest:
def __init__(self):
self.plugin = Plugin()
def start(self):
self.plugin.startServer()
def send(self,msg):
try:
self.plugin.send(msg)
except:
#I want to print send error here
# error could be connection fail
ptest = PluginTest()
#I m not starting the server so that I could get the connectionfail error
ptest.send('hi')
Can you suggest me any work around to get the exception in the PluginUser.send
method
_______________________________________________
Twisted-Python mailing list
[email protected]
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python