def setUp(self): super(TestServer, self).setUp() self.noop_event = threading.Event() processor = SleepService.Processor(SleepHandler(self.noop_event)) self.event_handler = SleepProcessorEventHandler() processor.setEventHandler(self.event_handler) self.server = TCppServer(processor) self.addCleanup(self.stopServer) # Let the kernel choose a port. self.server.setPort(0) self.server_thread = threading.Thread(target=self.server.serve) self.server_thread.start() for t in range(30): addr = self.server.getAddress() if addr: break time.sleep(0.1) self.assertTrue(addr) self.server_port = addr[1]
def getProcessor(self): processor = SleepService.Processor( SleepHandler(self.noop_event, self.shutdown_event)) self.event_handler = SleepProcessorEventHandler() processor.setEventHandler(self.event_handler) return processor