common_service.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:loopchain 作者: theloopkr 项目源码 文件源码
def run(self):
        self.start_server(self.outer_server, '[::]:' + str(self.__port))
        # Bind Only loopback address (ip4) - TODO IP6
        self.start_server(self.inner_server, conf.INNER_SERVER_BIND_IP + ':' + str(self.__inner_service_port))

        # Block Generator ? subscribe ?? ?? Block Generator ? peer ? channel ??? ????.
        # ??? peer ? gRPC ??? ??? ??? ? Block Generator ? subscribe ??? ??? ??.
        time.sleep(conf.WAIT_GRPC_SERVICE_START)

        try:
            while self.is_run():
                self.__run_loop_functions()
                time.sleep(conf.SLEEP_SECONDS_IN_SERVICE_NONE)
        except KeyboardInterrupt:
            logging.info("Server Stop by KeyboardInterrupt")
        finally:
            while not self.__subscriptions.empty():
                channel, subscribe_stub = self.__subscriptions.get()
                logging.info(f"Un subscribe to channel({channel}) server({subscribe_stub.target})")
                self.__un_subscribe(channel, self.__port, subscribe_stub)

            self.__stop_broadcast_process()

            if self.__inner_service_port is not None:
                self.inner_server.stop(0)
            self.outer_server.stop(0)

        logging.info("Server thread Ended.")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号