Example #1
0
def server_main(loop, path):
    """Run in the client after the fork."""
    loop.fork()
    logger.debug('forked function')
    sigintwatcher = pyev.Signal(
        signal.SIGINT, loop,
        lambda watcher, events: logger.info('interrupt ignored'))
    sigintwatcher.start()
    sigtermwatcher = pyev.Signal(signal.SIGTERM, loop, server_stop)
    sigtermwatcher.start()
    adder = AdderService()
    dispatcher = ObjectDispatch(adder)
    pickle_factory = PickleProtocolFactory(dispatcher)
    pickle_server = UnixServer(loop, pickle_factory, path)
    pickle_server.start()
    msgpack_factory = MsgPackProtocolFactory(dispatcher)
    msgpack_server = UnixServer(loop, msgpack_factory, path + '_mp')
    msgpack_server.start()

    logger.debug('running server loop')

    import cProfile
    cProfile.runctx('loop.loop()', None, {'loop': loop}, 'server_profile')

    logger.debug('server unlooped')
Example #2
0
 def test_unix_server(self):
     factory = ProtocolFactory()
     factory.protocol = Protocol
     server = UnixServer(loop, factory, "bogus")
     server = None
     # path should be cleaned up as soon as garbage collected
     gc.collect()
     self.assertTrue(not os.path.exists("bogus"))
Example #3
0
 def setUp(self):
     self.factory = MockFactory()
     self.factory.protocol = MockProtocol
     self.path = fpath + "/test_socket"
     self.server = UnixServer(loop, self.factory, self.path)
Example #4
0
 def listen_init(self):
     """Setup the service to listen for clients."""
     self.dispatcher = ObjectDispatch(self)
     self.factory = MsgPackProtocolFactory(self.dispatcher)
     self.server = UnixServer(self.loop, self.factory, self.path)
     self.server.start()