本文整理汇总了Python中grpc.UnaryStreamClientInterceptor方法的典型用法代码示例。如果您正苦于以下问题:Python grpc.UnaryStreamClientInterceptor方法的具体用法?Python grpc.UnaryStreamClientInterceptor怎么用?Python grpc.UnaryStreamClientInterceptor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类grpc
的用法示例。
在下文中一共展示了grpc.UnaryStreamClientInterceptor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: unary_stream
# 需要导入模块: import grpc [as 别名]
# 或者: from grpc import UnaryStreamClientInterceptor [as 别名]
def unary_stream(self,
method,
request_serializer=None,
response_deserializer=None):
def callable_factory(method):
return self._channel.unary_stream(method, request_serializer,
response_deserializer)
if isinstance(self._interceptor, grpc.UnaryStreamClientInterceptor):
return _InterceptingUnaryStreamMultiCallable(
method, callable_factory, self._interceptor)
else:
return callable_factory(method)
示例2: intercept_channel
# 需要导入模块: import grpc [as 别名]
# 或者: from grpc import UnaryStreamClientInterceptor [as 别名]
def intercept_channel(channel, *interceptors):
for interceptor in reversed(list(interceptors)):
if not isinstance(interceptor, grpc.UnaryUnaryClientInterceptor) and \
not isinstance(interceptor, grpc.UnaryStreamClientInterceptor) and \
not isinstance(interceptor, grpc.StreamUnaryClientInterceptor) and \
not isinstance(interceptor, grpc.StreamStreamClientInterceptor):
raise TypeError('interceptor must be '
'grpc.UnaryUnaryClientInterceptor or '
'grpc.UnaryStreamClientInterceptor or '
'grpc.StreamUnaryClientInterceptor or '
'grpc.StreamStreamClientInterceptor or ')
channel = _InterceptingChannel(channel, interceptor)
return channel