Skip to content

Commit 159c30d

Browse files
Fix close not awaitable, fix done is callable, fix return async next value
1 parent c8229e5 commit 159c30d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

betterproto/grpc/util/async_channel.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,14 @@ def __aiter__(self) -> AsyncIterator[T]:
100100
return self
101101

102102
async def __anext__(self) -> T:
103-
if self.done:
103+
if self.done():
104104
raise StopAsyncIteration
105105
self._waiting_recievers += 1
106106
try:
107107
result = await self._queue.get()
108108
if result is self.__flush:
109109
raise StopAsyncIteration
110+
return result
110111
finally:
111112
self._waiting_recievers -= 1
112113
self._queue.task_done()
@@ -151,7 +152,7 @@ async def send_from(
151152
await self._queue.put(item)
152153
if close:
153154
# Complete the closing process
154-
await self.close()
155+
self.close()
155156

156157
async def send(self, item: T):
157158
"""
@@ -168,7 +169,7 @@ async def recieve(self) -> Optional[T]:
168169
or None if the channel is closed before another item is sent.
169170
:return: An item from the channel
170171
"""
171-
if self.done:
172+
if self.done():
172173
raise ChannelDone("Cannot recieve from a closed channel")
173174
self._waiting_recievers += 1
174175
try:

0 commit comments

Comments
 (0)