|
1 | | -# Copyright 2024, Google LLC |
| 1 | +# Copyright 2025, Google LLC |
2 | 2 | # |
3 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
4 | 4 | # you may not use this file except in compliance with the License. |
|
24 | 24 |
|
25 | 25 |
|
26 | 26 | class _AsyncRequestQueueGenerator: |
27 | | - """An async helper for sending requests to a gRPC stream from a Queue. |
| 27 | + """_AsyncRequestQueueGenerator is a helper class for sending asynchronous requests to a gRPC stream from a Queue. |
28 | 28 |
|
29 | | - This generator takes requests off a given queue and yields them to gRPC. |
| 29 | + This generator takes asynchronous requests off a given queue and yields them to gRPC. |
30 | 30 |
|
31 | 31 | This helper is useful when you have an indeterminate, indefinite, or |
32 | 32 | otherwise open-ended set of requests to send through a request-streaming |
@@ -72,10 +72,9 @@ def __init__(self, queue: asyncio.Queue, initial_request=None): |
72 | 72 | self.call = None |
73 | 73 |
|
74 | 74 | def _is_active(self): |
75 | | - # Note: there is a possibility that this starts *before* the call |
76 | | - # property is set. So we have to check if self.call is set before |
77 | | - # seeing if it's active. We need to return True if self.call is None. |
78 | | - # See https://github.com/googleapis/python-api-core/issues/560. |
| 75 | + """ |
| 76 | + Returns true if the call is not set or not completed. |
| 77 | + """ |
79 | 78 | return self.call is None or not self.call.done() |
80 | 79 |
|
81 | 80 | async def __aiter__(self): |
@@ -200,7 +199,7 @@ async def send(self, request): |
200 | 199 | request (protobuf.Message): The request to send. |
201 | 200 | """ |
202 | 201 | if self.call is None: |
203 | | - raise ValueError("Can not send() on an RPC that has never been open()ed.") |
| 202 | + raise ValueError("Can not send() on an RPC that has never been opened.") |
204 | 203 |
|
205 | 204 | # Don't use self.is_active(), as ResumableBidiRpc will overload it |
206 | 205 | # to mean something semantically different. |
|
0 commit comments