當前位置: 首頁>>代碼示例>>Python>>正文


Python grpc.Server方法代碼示例

本文整理匯總了Python中grpc.Server方法的典型用法代碼示例。如果您正苦於以下問題:Python grpc.Server方法的具體用法?Python grpc.Server怎麽用?Python grpc.Server使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在grpc的用法示例。


在下文中一共展示了grpc.Server方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: import grpc [as 別名]
# 或者: from grpc import Server [as 別名]
def __init__(self):
        """Peer는 Radio Station 에 접속하여 leader 및 다른 Peer에 대한 접속 정보를 전달 받는다.

        :return:
        """
        self._peer_id = None
        self._node_key = bytes()
        self.p2p_outer_server: grpc.Server = None
        self._channel_infos = None

        self._peer_target = None
        self._rest_target = None
        self._peer_port = 0

        # gRPC service for Peer
        self._inner_service: PeerInnerService = None
        self._outer_service: PeerOuterService = None

        self._channel_services = {}
        self._rest_service = None

        ObjectManager().peer_service = self 
開發者ID:icon-project,項目名稱:loopchain,代碼行數:24,代碼來源:peer_service.py

示例2: __init__

# 需要導入模塊: import grpc [as 別名]
# 或者: from grpc import Server [as 別名]
def __init__(self, broker: str, backend: Optional[str] = None, max_tasks: Optional[int] = None,
                 max_workers: Optional[int] = None):  # pragma: no cover
        """Construct a Clearly Server instance.

        Args:
            broker: the broker being used by the celery system
            backend: the result backend being used by the celery system
            max_tasks: max tasks stored
            max_workers: max workers stored

        """
        max_tasks, max_workers = max_tasks or 10000, max_workers or 100
        logger.info('Creating memory: max_tasks=%d; max_workers=%d', max_tasks, max_workers)
        self._memory = State(max_tasks_in_memory=max_tasks, max_workers_in_memory=max_workers)

        queue_tasks, queue_workers = Queue(), Queue()  # hands new events to be distributed.
        try:
            self._listener = EventListener(broker, queue_tasks, queue_workers,
                                           self._memory, backend)
        except TimeoutError as e:
            logger.critical(e)
            sys.exit(1)

        self._dispatcher_tasks = StreamingDispatcher(queue_tasks, Role.TASKS)
        self._dispatcher_workers = StreamingDispatcher(queue_workers, Role.WORKERS)
        self._rpc = RPCService(self._memory, self._dispatcher_tasks, self._dispatcher_workers) 
開發者ID:rsalmei,項目名稱:clearly,代碼行數:28,代碼來源:server.py

示例3: start_server

# 需要導入模塊: import grpc [as 別名]
# 或者: from grpc import Server [as 別名]
def start_server(self, port: int = None, blocking: Optional[bool] = None) \
            -> Optional[grpc.Server]:  # pragma: no cover
        """Start the communication service in a new gRPC server instance.

        Args:
            port: the port clearly server will serve on
            blocking: if True manages gRPC server and blocks the main thread,
                just returns the server otherwise

        Returns:
            the gRPC server if not blocking, None otherwise

        """
        port = port or 12223
        logger.info('Initiating gRPC server: port=%d', port)

        gserver = grpc.server(futures.ThreadPoolExecutor())
        add_ClearlyServerServicer_to_server(self._rpc, gserver)
        gserver.add_insecure_port('[::]:{}'.format(port))

        logger.info('gRPC server ok')
        if blocking is False:
            return gserver

        gserver.start()

        one_day_in_seconds = 24 * 60 * 60
        import time
        try:
            while True:
                time.sleep(one_day_in_seconds)
        except KeyboardInterrupt:
            logger.info('Stopping gRPC server')
            gserver.stop(None)  # immediately. 
開發者ID:rsalmei,項目名稱:clearly,代碼行數:36,代碼來源:server.py


注:本文中的grpc.Server方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。