Python grpc.StreamStreamClientInterceptor() Examples

The following are 2 code examples of grpc.StreamStreamClientInterceptor(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module grpc , or try the search function .
Example #1
Source File: _interceptor.py    From python-grpc-demo with MIT License 5 votes vote down vote up
def stream_stream(self,
                      method,
                      request_serializer=None,
                      response_deserializer=None):

        def callable_factory(method):
            return self._channel.stream_stream(method, request_serializer,
                                               response_deserializer)

        if isinstance(self._interceptor, grpc.StreamStreamClientInterceptor):
            return _InterceptingStreamStreamMultiCallable(
                method, callable_factory, self._interceptor)
        else:
            return callable_factory(method) 
Example #2
Source File: _interceptor.py    From python-grpc-demo with MIT License 5 votes vote down vote up
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