Skip to content

Commit d528dd0

Browse files
committed
move comments from class level to method level
1 parent 69f061b commit d528dd0

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

google/api_core/bidi_async.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,7 @@
2929
_LOGGER = logging.getLogger(__name__)
3030

3131

32-
# The reason this is necessary is because it lets the user have control on
33-
# when they would want to send requests proto messages instead of sending all
34-
# of them initially.
35-
#
36-
# This is achieved via asynchronous queue (asyncio.Queue),
37-
# gRPC awaits until there's a message in the queue.
38-
#
39-
# Finally, it allows for retrying without swapping queues because if it does
40-
# pull an item off the queue when the RPC is inactive, it'll immediately put
41-
# it back and then exit. This is necessary because yielding the item in this
42-
# case will cause gRPC to discard it. In practice, this means that the order
43-
# of messages is not guaranteed. If preserving order is necessary it would be
44-
# easy to use a priority queue.
32+
4533
class _AsyncRequestQueueGenerator:
4634
"""_AsyncRequestQueueGenerator is a helper class for sending asynchronous
4735
requests to a gRPC stream from a Queue.
@@ -92,6 +80,20 @@ def _is_active(self) -> bool:
9280
return self.call is None or not self.call.done()
9381

9482
async def __aiter__(self):
83+
# The reason this is necessary is because it lets the user have
84+
# control on when they would want to send requests proto messages
85+
# instead of sending all of them initially.
86+
#
87+
# This is achieved via asynchronous queue (asyncio.Queue),
88+
# gRPC awaits until there's a message in the queue.
89+
#
90+
# Finally, it allows for retrying without swapping queues because if
91+
# it does pull an item off the queue when the RPC is inactive, it'll
92+
# immediately put it back and then exit. This is necessary because
93+
# yielding the item in this case will cause gRPC to discard it. In
94+
# practice, this means that the order of messages is not guaranteed.
95+
# If preserving order is necessary it would be easy to use a priority
96+
# queue.
9597
if self._initial_request is not None:
9698
if callable(self._initial_request):
9799
yield self._initial_request()

0 commit comments

Comments
 (0)