Exemplo n.º 1
0
def process_main(quit_event, queue_out, name, config):
    """进程主函数

    Args:
        quit_event (multiprocessing.Event): 需要退出的事件
        queue_out (multiprocessing.Queue): 每当收到数据时,将线程名填入此队列
        name (str): 线程名
        config (Entry): 配置表
    """
    log.init(name, config.enable_log)
    base64_log.init(name + '_raw', config.enable_raw)

    rtk_thread = RtkThread(name, config, lambda status: queue_out.put(
        (name, status)))
    rtk_thread.start()

    while rtk_thread.running:
        try:
            if quit_event.wait(timeout=3):  # true means event set
                break
        except KeyboardInterrupt:
            pass

    rtk_thread.running = False
    rtk_thread.join()

    log.close(name)
    base64_log.close(name + '_raw')
Exemplo n.º 2
0
def process_http(quit_event, names_queue, status_queue, http_port):
    """HTTP 进程主函数

    Args:
        quit_event (multiprocessing.Event): 需要退出的事件
        names_queue (multiprocessing.Queue): 更新基站名列表的队列
        status_queue (multiprocessing.Queue): 更新差分状态的队列
        http_port (int): web 服务器端口号
    """
    if http_port is not None:
        log.init(PROCESS_NAME)

    # start
    http_thread = HttpThread(http_port)

    if http_port is not None:
        http_thread.start()

    # loop
    try:
        while not quit_event.is_set():
            quit_event.wait(timeout=1)
            update_names_from_queue(names_queue, lambda rtk_names: RtkStatus.update_names(rtk_names))
            update_status_from_queue(status_queue,
                                     lambda name_status: RtkStatus.update_status(name_status[0], name_status[1]))
    except KeyboardInterrupt:
        pass

    # quit
    if http_port is not None:
        http_thread.shutdown()
        http_thread.join()

    log.close(PROCESS_NAME)
Exemplo n.º 3
0
def process_main(quit_event, queue_out, name, config):
    """进程主函数

    Args:
        quit_event (multiprocessing.Event): 需要退出的事件
        queue_out (multiprocessing.Queue): 每当收到数据时,将线程名填入此队列
        name (str): 线程名
        config (dict): 配置表
    """
    enable_log = config['enableLog'].lower() == 'true'
    log.init(name, enable_log)

    rtk_thread = RtkThread(name, config, lambda status: queue_out.put((name, status)))
    rtk_thread.start()

    while rtk_thread.running:
        try:
            if quit_event.wait(timeout=3):      # true means event set
                break
        except KeyboardInterrupt:
            pass

    rtk_thread.running = False
    rtk_thread.join()

    log.close(name)
Exemplo n.º 4
0
 def __init__(self):
     self.rtk_threads = {}
     self.thread_count = 0
     self.web_interface_thread = None
     self.is_interrupt = False
     self.rtk_names_queue = multiprocessing.Queue()
     self.status_queue = multiprocessing.Queue()
     # log init
     self.configs = self.load_config()
     if 'logPath' in self.configs.keys() and os.path.isdir(self.configs['logPath']):
         log.log_dir = self.configs['logPath']
     multiprocessing.current_process().name = 'rtk'
     log.init(multiprocessing.current_process().name, True)
Exemplo n.º 5
0
    def __init__(self):
        self.is_interrupt = False

        # config
        self.configs = config_loader.load_config()
        if 'logPath' in self.configs.keys() and os.path.isdir(
                self.configs['logPath']):
            log.log_dir = self.configs['logPath']
        if 'rawPath' in self.configs.keys() and os.path.isdir(
                self.configs['rawPath']):
            base64_log.log_dir = self.configs['rawPath']

        self.rtk_mgr = RtkProcessMgr(self.configs)

        # log init
        multiprocessing.current_process().name = 'rtk'
        log.init(multiprocessing.current_process().name, True)