当前位置: 首页>>代码示例>>Python>>正文


Python _channel._Rendezvous方法代码示例

本文整理汇总了Python中grpc._channel._Rendezvous方法的典型用法代码示例。如果您正苦于以下问题:Python _channel._Rendezvous方法的具体用法?Python _channel._Rendezvous怎么用?Python _channel._Rendezvous使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在grpc._channel的用法示例。


在下文中一共展示了_channel._Rendezvous方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: call_async

# 需要导入模块: from grpc import _channel [as 别名]
# 或者: from grpc._channel import _Rendezvous [as 别名]
def call_async(self, method_name, message, call_back=None, timeout=None, is_stub_reuse=True) -> grpc.Future:
        if timeout is None:
            timeout = conf.GRPC_TIMEOUT
        if call_back is None:
            call_back = self.print_broadcast_fail
        self.__make_stub(is_stub_reuse)

        def done_callback(result: _Rendezvous):
            if result.code() == grpc.StatusCode.OK:
                self.__update_last_succeed_time()
            call_back(result)

        try:
            stub_method = getattr(self.__stub, method_name)
            feature_future = stub_method.future(message, timeout)
            feature_future.add_done_callback(done_callback)
            return feature_future
        except Exception as e:
            logging.warning(f"gRPC call_async fail method_name({method_name}), message({message}): {e}, "
                            f"target({self.__target})") 
开发者ID:icon-project,项目名称:loopchain,代码行数:22,代码来源:stub_manager.py

示例2: send_to_route

# 需要导入模块: from grpc import _channel [as 别名]
# 或者: from grpc._channel import _Rendezvous [as 别名]
def send_to_route(self, route, r_hash_bytes):
        """
        Takes bare route (list) and tries to send along it,
        trying to fulfill the invoice labeled by the given hash.

        :param route: (list) of :class:`lib.routes.Route`
        :param r_hash_bytes: invoice identifier
        :return:
        """
        lnd_route = self.lnd_route(route)
        request = lnd.SendToRouteRequest(
            route=lnd_route,
            payment_hash_string=r_hash_bytes.hex(),
        )
        try:
            # timeout after 5 minutes
            return self._rpc.SendToRouteSync(request, timeout=5 * 60)
        except _Rendezvous:
            raise PaymentTimeOut 
开发者ID:bitromortac,项目名称:lndmanage,代码行数:21,代码来源:node.py

示例3: rcv_grpc

# 需要导入模块: from grpc import _channel [as 别名]
# 或者: from grpc._channel import _Rendezvous [as 别名]
def rcv_grpc(self):
        """
        This call establishes a GRPC stream to receive frames.
        """
        stub = ponsim_pb2_grpc.PonSimStub(self.get_channel())

        # Attempt to establish a grpc stream with the remote ponsim service
        self.frames = stub.ReceiveFrames(Empty())

        self.log.info('start-receiving-grpc-frames')

        try:
            for frame in self.frames:
                self.log.info('received-grpc-frame',
                              frame_len=len(frame.payload))
                self._rcv_frame(frame.payload)

        except _Rendezvous, e:
            log.warn('grpc-connection-lost', message=e.message) 
开发者ID:opencord,项目名称:voltha,代码行数:21,代码来源:ponsim_olt.py

示例4: start_packet_out_stream

# 需要导入模块: from grpc import _channel [as 别名]
# 或者: from grpc._channel import _Rendezvous [as 别名]
def start_packet_out_stream(self):

        def packet_generator():
            while 1:
                try:
                    packet = self.packet_out_queue.get(block=True, timeout=1.0)
                except Empty:
                    if self.stopped:
                        return
                else:
                    self.count_pkt_out += 1
                    self.log.debug('counters grpc_client OUT - {}'.format(self.count_pkt_out))
                    yield packet

        def stream_packets_out():
            generator = packet_generator()
            try:
                self.local_stub.StreamPacketsOut(generator)
            except _Rendezvous, e:
                self.log.error('grpc-exception', status=e.code())
                if e.code() == StatusCode.UNAVAILABLE:
                    os.system("kill -15 {}".format(os.getpid())) 
开发者ID:opencord,项目名称:voltha,代码行数:24,代码来源:grpc_client.py

示例5: start_packet_in_stream

# 需要导入模块: from grpc import _channel [as 别名]
# 或者: from grpc._channel import _Rendezvous [as 别名]
def start_packet_in_stream(self):

        def receive_packet_in_stream():
            streaming_rpc_method = self.local_stub.ReceivePacketsIn
            iterator = streaming_rpc_method(empty_pb2.Empty())
            try:
                for packet_in in iterator:
                    reactor.callFromThread(self.packet_in_queue.put,
                                           packet_in)
                    self.log.debug('enqued-packet-in',
                              packet_in=packet_in,
                              queue_len=len(self.packet_in_queue.pending))
                    self.count_pkt_in += 1
                    self.log.debug('counters grpc_client IN - {}'.format(self.count_pkt_in))
            except _Rendezvous, e:
                self.log.error('grpc-exception', status=e.code())
                if e.code() == StatusCode.UNAVAILABLE:
                    os.system("kill -15 {}".format(os.getpid())) 
开发者ID:opencord,项目名称:voltha,代码行数:20,代码来源:grpc_client.py

示例6: get_list_of_reachable_logical_devices_from_voltha

# 需要导入模块: from grpc import _channel [as 别名]
# 或者: from grpc._channel import _Rendezvous [as 别名]
def get_list_of_reachable_logical_devices_from_voltha(self):

        while self.running:
            self.log.debug('retrieve-logical-device-list')
            try:
                devices = yield \
                    self.grpc_client.list_reachable_logical_devices()

                for device in devices:
                    self.log.debug("reachable-logical-device-entry", id=device.id,
                                   datapath_id=device.datapath_id)

                returnValue(devices)

            except _Rendezvous, e:
                status = e.code()
                self.log.error('vcore-communication-failure', exception=e, status=status)
                if status == StatusCode.UNAVAILABLE or status == StatusCode.DEADLINE_EXCEEDED:
                    os.system("kill -15 {}".format(os.getpid()))

            except Exception as e:
                self.log.exception('logical-devices-retrieval-failure', exception=e) 
开发者ID:opencord,项目名称:voltha,代码行数:24,代码来源:connection_mgr.py

示例7: print_broadcast_fail

# 需要导入模块: from grpc import _channel [as 别名]
# 或者: from grpc._channel import _Rendezvous [as 别名]
def print_broadcast_fail(result: _Rendezvous):
        if result.code() != grpc.StatusCode.OK:
            logging.warning(f"call_async fail  : {result}\n"
                            f"cause by : {result.details()}") 
开发者ID:icon-project,项目名称:loopchain,代码行数:6,代码来源:stub_manager.py

示例8: __keep_grpc_connection

# 需要导入模块: from grpc import _channel [as 别名]
# 或者: from grpc._channel import _Rendezvous [as 别名]
def __keep_grpc_connection(self, result, timeout, stub_manager: StubManager):
        return isinstance(result, _Rendezvous) \
               and result.code() in (grpc.StatusCode.DEADLINE_EXCEEDED, grpc.StatusCode.UNAVAILABLE) \
               and stub_manager.elapsed_last_succeed_time() < timeout 
开发者ID:icon-project,项目名称:loopchain,代码行数:6,代码来源:broadcast_scheduler.py

示例9: __broadcast_retry_async

# 需要导入模块: from grpc import _channel [as 别名]
# 或者: from grpc._channel import _Rendezvous [as 别名]
def __broadcast_retry_async(self, peer_target, method_name, method_param, retry_times, timeout, stub, result):
        if isinstance(result, _Rendezvous) and result.code() == grpc.StatusCode.OK:
            return
        if isinstance(result, futures.Future) and not result.exception():
            return

        logging.debug(f"try retry to : peer_target({peer_target})\n")
        if retry_times > 0:
            try:
                stub_manager: StubManager = self.__audience[peer_target]
                if stub_manager is None:
                    logging.warning(f"broadcast_thread:__broadcast_retry_async Failed to connect to ({peer_target}).")
                    return
                retry_times -= 1
                is_stub_reuse = stub_manager.stub != stub or self.__keep_grpc_connection(result, timeout, stub_manager)
                self.__call_async_to_target(peer_target, method_name, method_param, is_stub_reuse, retry_times, timeout)
            except KeyError as e:
                logging.debug(f"broadcast_thread:__broadcast_retry_async ({peer_target}) not in audience. ({e})")
        else:
            if isinstance(result, _Rendezvous):
                exception = result.details()
            elif isinstance(result, futures.Future):
                exception = result.exception()

            logging.warning(f"__broadcast_run_async fail({result})\n"
                            f"cause by: {exception}\n"
                            f"peer_target({peer_target})\n"
                            f"method_name({method_name})\n"
                            f"retry_remains({retry_times})\n"
                            f"timeout({timeout})") 
开发者ID:icon-project,项目名称:loopchain,代码行数:32,代码来源:broadcast_scheduler.py

示例10: _retrieve_schema

# 需要导入模块: from grpc import _channel [as 别名]
# 或者: from grpc._channel import _Rendezvous [as 别名]
def _retrieve_schema(self):
        """
        Retrieve schema from gRPC end-point, and save all *.proto files in
        the work directory.
        """
        assert isinstance(self.channel, grpc.Channel)
        stub = SchemaServiceStub(self.channel)
        # try:
        schemas = stub.GetSchema(Empty(), timeout=120)
        # except _Rendezvous, e:
        #     if e.code == grpc.StatusCode.UNAVAILABLE:
        #
        #     else:
        #         raise e

        os.system('mkdir -p %s' % self.work_dir)
        os.system('rm -fr /tmp/%s/*' %
                  self.work_dir.replace('/tmp/', ''))  # safer

        for proto_file in schemas.protos:
            proto_fname = proto_file.file_name
            proto_content = proto_file.proto
            log.debug('saving-proto', fname=proto_fname, dir=self.work_dir,
                      length=len(proto_content))
            with open(os.path.join(self.work_dir, proto_fname), 'w') as f:
                f.write(proto_content)

            desc_content = decompress(proto_file.descriptor)
            desc_fname = proto_fname.replace('.proto', '.desc')
            log.debug('saving-descriptor', fname=desc_fname, dir=self.work_dir,
                      length=len(desc_content))
            with open(os.path.join(self.work_dir, desc_fname), 'wb') as f:
                f.write(desc_content)
        return schemas.swagger_from 
开发者ID:open-cloud,项目名称:xos,代码行数:36,代码来源:grpc_client.py

示例11: unlock_wallet

# 需要导入模块: from grpc import _channel [as 别名]
# 或者: from grpc._channel import _Rendezvous [as 别名]
def unlock_wallet(configuration, password: str):
        if password is None:
            return 'wallet not found'
        client = LndClient(configuration)
        try:
            client.unlock(password)
            return None
        except _Rendezvous as e:
            details = e.details()
            return details 
开发者ID:lightning-power-users,项目名称:node-launcher,代码行数:12,代码来源:lnd_unlocker.py

示例12: generate_seed

# 需要导入模块: from grpc import _channel [as 别名]
# 或者: from grpc._channel import _Rendezvous [as 别名]
def generate_seed(self, new_seed_password: str):
        try:
            generate_seed_response = self.client.generate_seed(
                seed_password=new_seed_password
            )
        except _Rendezvous:
            log.error('generate_seed error', exc_info=True)
            raise

        seed = generate_seed_response.cipher_seed_mnemonic

        keyring_service_name = f'lnd_seed'
        keyring_user_name = ''.join(seed[0:2])
        log.info(
            'generate_seed',
            keyring_service_name=keyring_service_name,
            keyring_user_name=keyring_user_name
        )

        self.keyring.set_password(
            service=keyring_service_name,
            username=keyring_user_name,
            password=' '.join(seed)
        )

        self.keyring.set_password(
            service=f'{keyring_service_name}_seed_password',
            username=keyring_user_name,
            password=new_seed_password
        )
        return seed 
开发者ID:lightning-power-users,项目名称:node-launcher,代码行数:33,代码来源:lnd_unlocker.py

示例13: stop

# 需要导入模块: from grpc import _channel [as 别名]
# 或者: from grpc._channel import _Rendezvous [as 别名]
def stop(self):
        request = ln.StopRequest()
        try:
            response = self.lnd_client.StopDaemon(request)
        except _Rendezvous:
            log.error('stop lnd error', exc_info=True)
            response = self.stop()
        return response 
开发者ID:lightning-power-users,项目名称:node-launcher,代码行数:10,代码来源:lnd_client.py

示例14: get_raw_network_graph

# 需要导入模块: from grpc import _channel [as 别名]
# 或者: from grpc._channel import _Rendezvous [as 别名]
def get_raw_network_graph(self):
        try:
            graph = self._rpc.DescribeGraph(lnd.ChannelGraphRequest())
        except _Rendezvous:
            logger.error(
                "Problem connecting to lnd. "
                "Either %s is not configured correctly or lnd is not running.",
                self.config_file)
            exit(1)
        return graph 
开发者ID:bitromortac,项目名称:lndmanage,代码行数:12,代码来源:node.py

示例15: get_node_info

# 需要导入模块: from grpc import _channel [as 别名]
# 或者: from grpc._channel import _Rendezvous [as 别名]
def get_node_info(self, pub_key):
        """
        Retrieves information on a node with a specific pub key.

        :param pub_key: node public key
        :type pub_key: str
        :return: node information including all channels
        :rtype: dict
        """
        request = lnd.NodeInfoRequest(pub_key=pub_key, include_channels=True)
        try:
            response = self._rpc.GetNodeInfo(request)
        except _Rendezvous as e:
            if e.details() == "unable to find node":
                logger.info(
                    "LND node has no information about node with pub key %s.",
                    pub_key)
            raise KeyError

        node_info = {
            'alias': response.node.alias,
            'color': response.node.color,
            'channels': response.channels,
            'last_update': response.node.last_update,
            'pub_key': pub_key,
            'num_channels': int(response.num_channels),
            'total_capacity': int(response.total_capacity),  # sat
        }

        addresses = [address.addr for address in response.node.addresses]
        node_info['addresses'] = addresses

        return node_info 
开发者ID:bitromortac,项目名称:lndmanage,代码行数:35,代码来源:node.py


注:本文中的grpc._channel._Rendezvous方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。