Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,7 @@ def autodoc_process_signature(

# currently undocumented things
logger = getLogger("trio")
UNDOCUMENTED = {
"trio.MemorySendChannel",
"trio.MemoryReceiveChannel",
"trio.MemoryChannelStatistics",
"trio._subprocess.HasFileno.fileno",
"trio.lowlevel.ParkingLot.broken_by",
}
UNDOCUMENTED: set[str] = set()


def autodoc_process_docstring(
Expand Down
6 changes: 6 additions & 0 deletions docs/source/reference-lowlevel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,12 @@ Wait queue abstraction
.. autoclass:: ParkingLot
:members:
:undoc-members:
:exclude-members: broken_by

.. attribute:: broken_by

The tasks that broke this parking lot. This list is empty until
:meth:`break_lot` is called.

.. autoclass:: ParkingLotStatistics
:members:
Expand Down
1 change: 1 addition & 0 deletions newsfragments/3221.doc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Document `MemorySendChannel`, `MemoryReceiveChannel`, and `MemoryChannelStatistics` in the API reference.
36 changes: 36 additions & 0 deletions src/trio/_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,26 @@ def __init__(self, max_buffer_size: int | float) -> None: # noqa: PYI041

@attrs.frozen
class MemoryChannelStatistics:
"""Statistics for a memory channel.

This is returned by `MemorySendChannel.statistics` and
`MemoryReceiveChannel.statistics`.

Attributes:
current_buffer_used: The number of values currently stored in the
channel buffer.
max_buffer_size: The maximum number of values allowed in the buffer, as
passed to `open_memory_channel`.
open_send_channels: The number of open `MemorySendChannel` endpoints
pointing to this channel.
open_receive_channels: The number of open `MemoryReceiveChannel`
endpoints pointing to this channel.
tasks_waiting_send: The number of tasks blocked in
`MemorySendChannel.send` on this channel, across all clones.
tasks_waiting_receive: The number of tasks blocked in
`MemoryReceiveChannel.receive` on this channel, across all clones.
"""

current_buffer_used: int
max_buffer_size: int | float
open_send_channels: int
Expand Down Expand Up @@ -152,6 +172,14 @@ def statistics(self) -> MemoryChannelStatistics:
@final
@attrs.define(eq=False, repr=False, slots=False)
class MemorySendChannel(SendChannel[SendType], metaclass=NoPublicConstructor):
"""The sending side of an in-memory channel.

A `MemorySendChannel` is created by `open_memory_channel`. Values sent on
it are delivered to the matching `MemoryReceiveChannel`. Send channels can
be cloned to give multiple producers independent endpoints that all feed
the same underlying channel.
"""

_state: MemoryChannelState[SendType]
_closed: bool = False
# This is just the tasks waiting on *this* object. As compared to
Expand Down Expand Up @@ -300,6 +328,14 @@ async def aclose(self) -> None:
@final
@attrs.define(eq=False, repr=False, slots=False)
class MemoryReceiveChannel(ReceiveChannel[ReceiveType], metaclass=NoPublicConstructor):
"""The receiving side of an in-memory channel.

A `MemoryReceiveChannel` is created by `open_memory_channel`. It receives
values from the matching `MemorySendChannel`. Receive channels can be
cloned to give multiple consumers independent endpoints that share the
same underlying channel.
"""

_state: MemoryChannelState[ReceiveType]
_closed: bool = False
_tasks: set[trio._core._run.Task] = attrs.Factory(set)
Expand Down
4 changes: 3 additions & 1 deletion src/trio/_subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ def pidfd_open(fd: int, flags: int) -> int:
class HasFileno(Protocol):
"""Represents any file-like object that has a file descriptor."""

def fileno(self) -> int: ...
def fileno(self) -> int:
"""Return the integer file descriptor for this object."""
...


@final
Expand Down
7 changes: 0 additions & 7 deletions src/trio/_tests/_check_type_completeness.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,13 @@
],
"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\"",
"No docstring found for function \"trio._highlevel_socket.SocketStream.wait_send_all_might_not_block\"",
"No docstring found for function \"trio._highlevel_socket.SocketStream.send_eof\"",
"No docstring found for function \"trio._highlevel_socket.SocketStream.receive_some\"",
"No docstring found for function \"trio._highlevel_socket.SocketStream.aclose\"",
"No docstring found for function \"trio._subprocess.HasFileno.fileno\"",
"No docstring found for class \"trio._sync.AsyncContextManagerMixin\"",
"No docstring found for function \"trio._sync._HasAcquireRelease.acquire\"",
"No docstring found for function \"trio._sync._HasAcquireRelease.release\"",
Expand Down
Loading