J
Jean-Pierre Bergamin
Me again...
Is there any possibility to kill a SocketServer that was started like this:
class ServerThread(threading.Thread):
class MyHandler(SocketServer.StreamRequestHandler):
def handle(self):
line = self.rfile.readline()
self.wfile.write(line.upper())
def run(self):
s = SocketServer.TCPServer(('', 1234), self.MyHandler)
s.server_forever()
def stop_server()
# Any chance to stop the server here???
what_to_do() # ????????
server_thread = ServerThread()
server_thread.start()
# do other things
server_thread.stop_server()
The problem is, that I found no way to interrupt the blocking call to
self.rfile.readline(). Is there a way to do that?
Using an asynchronous server is not an option.
Thanks in advance
James
Is there any possibility to kill a SocketServer that was started like this:
class ServerThread(threading.Thread):
class MyHandler(SocketServer.StreamRequestHandler):
def handle(self):
line = self.rfile.readline()
self.wfile.write(line.upper())
def run(self):
s = SocketServer.TCPServer(('', 1234), self.MyHandler)
s.server_forever()
def stop_server()
# Any chance to stop the server here???
what_to_do() # ????????
server_thread = ServerThread()
server_thread.start()
# do other things
server_thread.stop_server()
The problem is, that I found no way to interrupt the blocking call to
self.rfile.readline(). Is there a way to do that?
Using an asynchronous server is not an option.
Thanks in advance
James