You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the example provided in the docs using the open() method on a stream creates a context manager that can be used to send and receive messages. One of the purposes of a context manager is to automate cleanup.
async with stub.BiDiMethod.open() as stream:
await stream.send_request() # needed to initiate a call
while True:
task = await task_queue.get()
if task is None:
await stream.end()
break
else:
await stream.send_message(task)
result = await stream.recv_message()
await result_queue.add(task)
Why is the call to stream.end() necessary? Could that not be part of the stream.__aexit__() method?
The text was updated successfully, but these errors were encountered:
It's not obvious to me why the context manager doesn't call stream.cancel() (ie an explicit hangup, rather than just signalling that we're not going to send more data). Once we exit the context, the stream shouldn't be usable any more anyway, right?
In the example provided in the docs using the
open()
method on a stream creates a context manager that can be used to send and receive messages. One of the purposes of a context manager is to automate cleanup.Why is the call to
stream.end()
necessary? Could that not be part of thestream.__aexit__()
method?The text was updated successfully, but these errors were encountered: