def __init__(self, logMessages=False): super(GuiProcess, self).__init__() self.pid = Process.attach("GUI", self) self.messages = PatternMatcher() self.isOpen = True self.logger = Process.logger() self.logMessages = logMessages
def event(self, ev): """ Handle events sent to the object. """ if ev.type() == MessageReceivedEvent.Type: if self.logMessages: self.logger.info("Received message %s.", repr(ev.m)) try: self.messages.match(ev.m) except Exception: Process.logger().exception("An exception was raised by the process") return True else: return False
def testClientServerNegociation(self): """ Negociation should work out with client and server using the same negociation code. """ pid = Process.current() c, s = Pipe.create() def server(): name = negociateProtocol(s, False) Process.send(pid, name) def client(): name = negociateProtocol(c, True) Process.send(pid, name) Process.spawn(server) Process.spawn(client) firstName = Process.receive() secondName = Process.receive() for name in (firstName, secondName): self.assertTrue(name in Supported) self.assertEqual(firstName, secondName)
def client(): name = negociateProtocol(c, True) Process.send(pid, name)
def server(): name = negociateProtocol(s, False) Process.send(pid, name)
def __exit__(self, type, e, traceback): Process.detach()