It's possible for a connection to terminate before a response has been returned. In this case, we end the stream iterator
def consume(self, message_type):
"""Consume the data in this stream by yielding `message_type` messages,
or raising if the stream was closed with an error.
"""
while True:
item = self.queue.get()
if isinstance(item, GrpcError):
raise item
elif item is STREAM_END:
break
If a stream is closed before a response is returned then the stream 'breaks', raising a StopIteration exception which we need to handle. We can't just check if it's closed as we want it to raise any errors.
Notes:
Not sure if there's a better error message. Likely there is.
Summary
It's possible for a connection to terminate before a response has been returned. In this case, we end the stream iterator
If a stream is closed before a response is returned then the stream 'breaks', raising a StopIteration exception which we need to handle. We can't just check if it's closed as we want it to raise any errors.
Notes: