本文整理匯總了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