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] 
> <javascript:>> 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] 
>> <javascript:>> 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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/e93d5c60-693c-4790-b107-8a851f42df9fo%40googlegroups.com.

Reply via email to