Hi Ian<br>
<br>
I ran into this just recently, but am not entirely certain I
found the best solution. I needed to be able to switch the port the
reactor was listening on without restarting the reactor. Here's how I
did it:<br>
<br>
<blockquote type="cite"><tt>
&nbsp;&nbsp;&nbsp; def startListener(self, port, interface=&quot;<a href="http://127.0.0.1">127.0.0.1</a>&quot;):<br>
  <br>


&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.iListeningPort = reactor.listenTCP(<br>


&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; port, <br>


&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.factory,<br>


&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; interface=interface<br>


&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )<br>

&nbsp;&nbsp;&nbsp; def restartListener(self, port, interface=&quot;<a href="http://127.0.0.1">127.0.0.1</a>&quot;):<br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.iListeningPort.stopListening()<br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.startListener(port, interface)</tt>

  <br>

</blockquote>
<br>
I'm not sure if doing this will have any unintended side-effects, but
so far it seems to have done the trick. If someone else on the list
could confirm this does what I think it does (and what Ian is looking
for) that would be great.<br>
<br>
Best,<br>
<br>
Travis<br><br><div><span class="gmail_quote">On 8/1/06, <b class="gmail_sendername"><a href="mailto:ian.parker@facilita.co.uk">ian.parker@facilita.co.uk</a></b> &lt;<a href="mailto:ian.parker@facilita.co.uk">ian.parker@facilita.co.uk
</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">I have created an internet server that is started in a thread from a Python QT GUI.
<br><br>I can call reactor.stop() and sucessfully get notified of shutdown and the run thread terminates, the TCP/IP listen port is closed.<br><br>When I restart it by calling reactor.listenTCP() and&nbsp;&nbsp;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&nbsp;&nbsp;running reactor thread or terminate the TCP listener.
<br><br>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().<br><br>What I need is to stop and re-start the listenTCP.&nbsp;&nbsp;Is there a way to do this?
<br><br>Thanks,<br>Ian<br><br>_______________________________________________<br>Twisted-Python mailing list<br><a href="mailto:Twisted-Python@twistedmatrix.com">Twisted-Python@twistedmatrix.com</a><br><a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python">
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br></blockquote></div><br>