Exemple #1
0
 def start_servers(self):
     print("Starting servers...")
     ws_server = WebSocketServer(self.host, self.ws_port, 2000)
     http_server = BaseHTTPServer.HTTPServer((self.host, self.port),
                                             HTTPRequestHandler)
     th2 = threading.Thread(target=http_server.serve_forever)
     threads = [th2]
     for t in threads:
         t.daemon = True
         t.start()
     print("GUI available @ %s:%s" % (self.host, self.port))
     while len(threads) > 0:
         try:
             # Join all threads using a timeout so it doesn't block
             # Filter out threads which have been joined or are None
             asyncore.loop()
             threads = [
                 t.join(1000) for t in threads
                 if t is not None and t.isAlive()
             ]
         except KeyboardInterrupt:
             ws_server.kill_all_processes()
             ws_server.ExitNow('WS Server is quitting!')
             http_server.shutdown()
             os._exit(1)
Exemple #2
0
 def start_servers(self):
     print("Starting servers...")
     ws_server = WebSocketServer("", self.ws_port, 2000)
     http_server = BaseHTTPServer.HTTPServer((self.host, self.port), HTTPRequestHandler)
     th2 = threading.Thread(target=http_server.serve_forever)
     threads = [th2]
     for t in threads:
         t.daemon = True
         t.start()
     print("GUI available @ %s:%s" % (self.host, self.port))
     while len(threads) > 0:
         try:
             # Join all threads using a timeout so it doesn't block
             # Filter out threads which have been joined or are None
             asyncore.loop()
             threads = [t.join(1000) for t in threads if t is not None and t.isAlive()]
         except KeyboardInterrupt:
             ws_server.kill_all_processes()
             ws_server.ExitNow('WS Server is quitting!')
             http_server.shutdown()
             os._exit(1)