示例#1
0
 def started(self):
     """
     Return True if the server is started, False otherwise.
     """
     client = None
     try:
         client = TimblClient(port=self.port)
     except (ConnectionError, socket.error):
         del client
         return False
     return True
示例#2
0
    def __init__(self, host, port, settings, **kwargs):
        """
        Initializes a MBClassifier, sets up a L{TimblServer}
        and connects to this server via an instance of L{TimblClient}.

        Args:
            - host (str): Host specifies the server address (localhost by default)
            - port (int): Port specifies the server tcp communicating port.
            - settings (dict): the settings used by Timbl (see :mod:`config`)
        """
        self.server = TimblServer(
            host=host,
            port=port,
            features=settings,
            classifier=self.__class__.__name__,
        )
        self.server.run()
        self.client = TimblClient(host=host, port=port)

        # register the kill method to make sure the timblserver is killed
        # at exiting the interactive shell
        atexit.register(self.kill)