示例#1
0
class EventsRpcServer(SocketRpcServer):
    """
    RPC server used in server and component interfaces to receive messages.
    """
    def __init__(self, port, host='localhost'):
        """
        Initialize a RPC server.

        :param port: the port in which to listen for incoming messages
        :type port: int
        :param host: the address to bind to
        :type host: str
        """
        SocketRpcServer.__init__(self, port, host)
        self._server = None

    def run(self):
        """
        Run the server.
        """
        logger.info('Running server on port %d.' % self.port)
        # parent implementation does not hold the server instance, so we do it
        # here.
        self._server = ThreadedTCPServer((self.host, self.port), SocketHandler,
                                         self)
        # if we chose to use a random port, fetch the port number info.
        if self.port is 0:
            self.port = self._server.socket.getsockname()[1]
        self._server.serve_forever()

    def stop(self):
        """
        Stop the server.
        """
        self._server.shutdown()
示例#2
0
 def run(self):
     """
     Run the server.
     """
     logger.info('Running server on port %d.' % self.port)
     # parent implementation does not hold the server instance, so we do it
     # here.
     self._server = ThreadedTCPServer((self.host, self.port), SocketHandler,
                                      self)
     # if we chose to use a random port, fetch the port number info.
     if self.port is 0:
         self.port = self._server.socket.getsockname()[1]
     self._server.serve_forever()
示例#3
0
 def run(self):
     """
     Run the server.
     """
     logger.info('Running server on port %d.' % self.port)
     # parent implementation does not hold the server instance, so we do it
     # here.
     self._server = ThreadedTCPServer((self.host, self.port),
                                      SocketHandler, self)
     # if we chose to use a random port, fetch the port number info.
     if self.port is 0:
         self.port = self._server.socket.getsockname()[1]
     self._server.serve_forever()
示例#4
0
class EventsRpcServer(SocketRpcServer):
    """
    RPC server used in server and client interfaces to receive messages.
    """

    def __init__(self, port, host='localhost'):
        """
        Initialize a RPC server.

        :param port: the port in which to listen for incoming messages
        :type port: int
        :param host: the address to bind to
        :type host: str
        """
        SocketRpcServer.__init__(self, port, host)
        self._server = None

    def run(self):
        """
        Run the server.
        """
        logger.info('Running server on port %d.' % self.port)
        # parent implementation does not hold the server instance, so we do it
        # here.
        self._server = ThreadedTCPServer((self.host, self.port),
                                         SocketHandler, self)
        # if we chose to use a random port, fetch the port number info.
        if self.port is 0:
            self.port = self._server.socket.getsockname()[1]
        self._server.serve_forever()

    def stop(self):
        """
        Stop the server.
        """
        self._server.shutdown()