def initialize(self): WebSocketFilePublisher.initialize(self) # find a port we can bind for our webserver self.webserver_port = getUnboundPort() self.debug("attempting to bind %i for webserver" % self.webserver_port) server = HTTPServer(('0.0.0.0', self.webserver_port), HeaderReflectHandler) self._running = True # TODO: start the webserver def run_server(): while self._running: server.handle_request() t = threading.Thread(target=run_server) t.daemon = True t.start()
def finalize(self): WebSocketFilePublisher.finalize(self) self._running = False