It seems that I'm getting OT on this thread. I've created a new one 
<https://groups.google.com/forum/#!topic/grpc-io/NGwmSMrOADM>.

On Saturday, June 6, 2020 at 2:53:05 AM UTC+8, Lidi Zheng wrote:
>
> Your observation is right that if an interceptor returns a generator 
> instead of a grpc.Call object, downstream applications will lose access to 
> initial_metadata, trailing_metadata, etc..
>
> However, in the API reference [1], the streaming interceptors define the 
> return value as:
>
>     > An object that is both a Call for the RPC and an iterator of 
> response values. Drawing response values from the returned Call-iterator 
> may raise RpcError indicating termination of the RPC with non-OK status.
>
> So, returning a generator without wrapping it as grpc.Call is not fully 
> supported. Given that, this support can be implementWe always welcome 
> contributors.
>
> [1] 
> https://grpc.github.io/grpc/python/grpc.html#grpc.StreamStreamClientInterceptor
>
> <https://grpc.github.io/grpc/python/grpc.html#grpc.StreamStreamClientInterceptor>
>
> On Fri, Jun 5, 2020 at 3:16 AM <[email protected] <javascript:>> wrote:
>
>> It doesn't work if an interceptor intercepts the responses.
>> Considering there is such an interceptor:
>> def wrapper(iterator):
>>   for entry in iterator:
>>     yield entry
>> class MyInterceptor(grpc.StreamStreamClientInterceptor):
>>   def intercept_stream_stream(self, continuation, client_call_details, 
>> request_iterator):
>>     return wrapper(continuation(client_call_details, request_iterator))
>> Well I know I could delegate a method `initial_metadata` to the original 
>> iterator, but unfortunately, I've seen many interceptors written in the way 
>> above, causing that I couldn't retrieve the initial metadata from last 
>> interceptor.
>> Any idea?
>>
>> 在 2016年4月6日星期三 UTC+8上午9:08:36,Nathaniel Manista写道:
>>>
>>> On Tue, Apr 5, 2016 at 9:58 AM, Tang Weiyu <[email protected]> wrote:
>>>
>>>> Definition of rpc:
>>>>   rpc telemetrySubscribe(SubscriptionRequest)     returns (stream 
>>>> OpenConfigData) {}
>>>>
>>>
>>> What's important here is that the RPC is response-streaming: it will 
>>> return zero, or one, or many more responses.
>>>
>>> How to get metadata from client side for streaming type of rpc call?
>>>>
>>>> On Mon, Apr 4, 2016 at 5:15 PM, Tang Weiyu <[email protected]> wrote:
>>>>
>>>>> Thanks Nathaniel, unfortunately the returned response don't have those 
>>>>> 2 methods, though I did get the returned response in the form of stream 
>>>>> Type defined in proto file RCP.
>>>>> Anything missing here?
>>>>>
>>>>> for data,call in stub.Subscribe(sub_req, _TIMEOUT_SECONDS):
>>>>>   metadata = data.initial_metadata()
>>>>>
>>>>
>>> Unpacking the iterator returned by your RPC invocation appears to be a 
>>> mistake here. I suspect that this should be something like:
>>>
>>> my_response_iterator = stub.Subscribe(sub_req, _TIMEOUT_SECONDS)
>>> my_initial_metadata = my_response_iterator.initial_metadata()
>>> for my_response in my_response_iterator:
>>>   <take some action for each response value>
>>> my_terminal_metadata = my_response_iterator.terminal_metadata()
>>>
>>> Again, the critical part is that the RPC is response-streaming - the 
>>> code for a response-unary RPC would look very different.
>>> -N
>>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "grpc.io" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/grpc-io/e93d5c60-693c-4790-b107-8a851f42df9fo%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/grpc-io/e93d5c60-693c-4790-b107-8a851f42df9fo%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/cefd0dad-ae11-4441-8c19-0d51a909aaa9o%40googlegroups.com.

Reply via email to