diff --git a/src/trio/_channel.py b/src/trio/_channel.py index 05037d813..8e68cf07f 100644 --- a/src/trio/_channel.py +++ b/src/trio/_channel.py @@ -118,6 +118,23 @@ def __init__(self, max_buffer_size: int | float) -> None: # noqa: PYI041 @attrs.frozen class MemoryChannelStatistics: + """Statistics about a memory channel. + + Attributes: + current_buffer_used: The number of items currently stored in the + channel buffer. + max_buffer_size: The maximum number of items allowed in the buffer, + as passed to :func:`open_memory_channel`. + open_send_channels: The number of open :class:`MemorySendChannel` + endpoints pointing to this channel. + open_receive_channels: The number of open :class:`MemoryReceiveChannel` + endpoints pointing to this channel. + tasks_waiting_send: The number of tasks blocked in ``send`` on this + channel (summing over all clones). + tasks_waiting_receive: The number of tasks blocked in ``receive`` on + this channel (summing over all clones). + """ + current_buffer_used: int max_buffer_size: int | float open_send_channels: int @@ -152,6 +169,13 @@ def statistics(self) -> MemoryChannelStatistics: @final @attrs.define(eq=False, repr=False, slots=False) class MemorySendChannel(SendChannel[SendType], metaclass=NoPublicConstructor): + """The sending end of a memory channel. + + Memory channels are created using :func:`open_memory_channel`, which + returns a pair of (:class:`MemorySendChannel`, :class:`MemoryReceiveChannel`). + See :func:`open_memory_channel` for full documentation. + """ + _state: MemoryChannelState[SendType] _closed: bool = False # This is just the tasks waiting on *this* object. As compared to @@ -300,6 +324,13 @@ async def aclose(self) -> None: @final @attrs.define(eq=False, repr=False, slots=False) class MemoryReceiveChannel(ReceiveChannel[ReceiveType], metaclass=NoPublicConstructor): + """The receiving end of a memory channel. + + Memory channels are created using :func:`open_memory_channel`, which + returns a pair of (:class:`MemorySendChannel`, :class:`MemoryReceiveChannel`). + See :func:`open_memory_channel` for full documentation. + """ + _state: MemoryChannelState[ReceiveType] _closed: bool = False _tasks: set[trio._core._run.Task] = attrs.Factory(set) diff --git a/src/trio/_tests/_check_type_completeness.json b/src/trio/_tests/_check_type_completeness.json index 6e8c54ea8..e5414cfe5 100644 --- a/src/trio/_tests/_check_type_completeness.json +++ b/src/trio/_tests/_check_type_completeness.json @@ -18,12 +18,6 @@ ], "Windows": [], "all": [ - "No docstring found for class \"trio.MemoryReceiveChannel\"", - "No docstring found for class \"trio._channel.MemoryReceiveChannel\"", - "No docstring found for class \"trio.MemoryChannelStatistics\"", - "No docstring found for class \"trio._channel.MemoryChannelStatistics\"", - "No docstring found for class \"trio.MemorySendChannel\"", - "No docstring found for class \"trio._channel.MemorySendChannel\"", "No docstring found for class \"trio._core._run.Task\"", "No docstring found for class \"trio._socket.SocketType\"", "No docstring found for function \"trio._highlevel_socket.SocketStream.send_all\"",