@@ -49,15 +49,16 @@ async def __anext__(self) -> T:
4949 raise StopAsyncIteration () from exc
5050
5151 @abstractmethod
52- async def ready (self ) -> None :
53- """Wait until the receiver is ready with a value.
52+ async def ready (self ) -> bool :
53+ """Wait until the receiver is ready with a value or an error .
5454
55- Once a call to `ready()` has finished, the value should be read with a call to
56- `consume()`.
55+ Once a call to `ready()` has finished, the value should be read with
56+ a call to `consume()` (`receive()` or iterated over). The receiver will
57+ remain ready (this method will return immediately) until it is
58+ consumed.
5759
58- Raises:
59- ReceiverStoppedError: if the receiver stopped producing messages.
60- ReceiverError: if there is some problem with the receiver.
60+ Returns:
61+ Whether the receiver is still active.
6162 """
6263
6364 @abstractmethod
@@ -68,6 +69,10 @@ def consume(self) -> T:
6869
6970 Returns:
7071 The next value received.
72+
73+ Raises:
74+ ReceiverStoppedError: if the receiver stopped producing messages.
75+ ReceiverError: if there is some problem with the receiver.
7176 """
7277
7378 def __aiter__ (self ) -> Receiver [T ]:
@@ -81,13 +86,13 @@ def __aiter__(self) -> Receiver[T]:
8186 async def receive (self ) -> T :
8287 """Receive a message from the channel.
8388
89+ Returns:
90+ The received message.
91+
8492 Raises:
8593 ReceiverStoppedError: if there is some problem with the receiver.
8694 ReceiverError: if there is some problem with the receiver.
8795
88- Returns:
89- The received message.
90-
9196 # noqa: DAR401 __cause__ (https://github.com/terrencepreilly/darglint/issues/181)
9297 """
9398 try :
@@ -169,14 +174,26 @@ def __init__(self, recv: Receiver[T], transform: Callable[[T], U]) -> None:
169174 self ._recv = recv
170175 self ._transform = transform
171176
172- async def ready (self ) -> None :
173- """Wait until the receiver is ready with a value."""
174- await self ._recv .ready () # pylint: disable=protected-access
177+ async def ready (self ) -> bool :
178+ """Wait until the receiver is ready with a value or an error.
179+
180+ Once a call to `ready()` has finished, the value should be read with
181+ a call to `consume()` (`receive()` or iterated over). The receiver will
182+ remain ready (this method will return immediately) until it is
183+ consumed.
184+
185+ Returns:
186+ Whether the receiver is still active.
187+ """
188+ return await self ._recv .ready () # pylint: disable=protected-access
175189
176190 def consume (self ) -> U :
177191 """Return a transformed value once `ready()` is complete.
178192
179193 Returns:
180194 The next value that was received.
195+
196+ Raises:
197+ ChannelClosedError: if the underlying channel is closed.
181198 """
182199 return self ._transform (self ._recv .consume ()) # pylint: disable=protected-access
0 commit comments