Application-supplied message iterators are required to be iterators 
<http://www.grpc.io/grpc/python/_modules/grpc.html#StreamUnaryMultiCallable.__call__>.
 
It is currently the case that when an application passes an object that is 
not an iterator 
<https://docs.python.org/2/library/stdtypes.html#iterator-types> of 
messages where one is required gRPC Python is not as helpful in handling 
the defect as it could be <https://github.com/grpc/grpc/issues/8231>, and we’re 
looking at remedying that 
<https://github.com/thunderboltsid/grpc/commit/f3031c3ccba62f0856c79844f673836dcdcb0cba>.
 
Along the way, we’ve discovered that the current behavior of gRPC Python 
when passed an iterable of messages is to do what the application probably 
intended: populate the RPC’s request stream with the messages. The way 
we’ve currently drafted the change, gRPC Python instead would in the future 
detect this application-level type error and abort the RPC.

Is there anyone out there passing lists, tuples, or other iterables of 
request messages where the API requires an iterator of request messages? 
(Embarrassingly, we’ve made this mistake in our own tests.) If so, would it 
be onerous or undesirable to have to pass an iterator over the messages in 
the iterable rather than the iterable itself? There might be people out 
there who might be using this unguaranteed behaviour in production. Is this 
unguaranteed behaviour something that gRPC Python should start supporting 
formally, or may it be dropped? Since it would be trivial to support 
iterables with a single `iterator = iter(request_iterator_or_iterable)`, 
the question has nothing to do with implementation complexity or 
performance and boils down to whether we want to provide greater 
convenience to application developers at the cost of an increase in 
requirements placed on gRPC Python.


Cheers,

Sid

-- 
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 grpc-io+unsubscr...@googlegroups.com.
To post to this group, send email to grpc-io@googlegroups.com.
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/83cf7763-39f1-44dc-8633-00f8a6f0d8d7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to