コード例 #1
0
def run_master():
    """Run master Daemon. It will run in the same thread."""
    logging.info('Init Master')
    master_config = get_master_config()
    logging.info(master_config)
    master = Master((master_config.host, master_config.port), ClientTCPHandler)

    # Activate the server; this will keep running until you
    # interrupt the program with Ctrl-C
    try:
        logging.info("Start serving")
        master.serve_forever()
    except KeyboardInterrupt:
        master.stop()
        sys.exit(0)
コード例 #2
0
ファイル: worker.py プロジェクト: McKenzyPG/plynx
def run_worker(worker_id=None):
    """Run master Daemon. It will run in the same thread.

    Args:
        worker_id   (str):  Worker ID. It will be generated if empty or not given
    """
    master_config = get_master_config()
    logging.info('Init Worker')
    logging.info(master_config)
    worker = Worker(
        worker_id=worker_id,
        host=master_config.host,
        port=master_config.port,
    )

    try:
        worker.serve_forever()
    except KeyboardInterrupt:
        worker.stop()