[Twisted-Python] Restarting a reactor listener

ian.parker at facilita.co.uk ian.parker at facilita.co.uk
Tue Aug 1 13:27:54 EDT 2006

I have created an internet server that is started in a thread from a Python QT GUI.

I can call reactor.stop() and sucessfully get notified of shutdown and the run thread terminates, the TCP/IP listen port is closed.

When I restart it by calling reactor.listenTCP() and  reactor.run(installSignalHandlers=0) a second time I find that things don't work correctly. e.g. TCP calls are accepted and my protocol.dataReceived() is called but then calling reactor.callInThread(self.blockingMethod, data) does nothing. Also calling stop() a second time does not stop the  running reactor thread or terminate the TCP listener.

I have tried numerous options, and have been careful to avoid any conflicts with the GUI threads. It appears that the reactor is not being restarted correctly after stop() and a second run().

What I need is to stop and re-start the listenTCP.  Is there a way to do this?


More information about the Twisted-Python mailing list