Skip to content

Commit d2eb09c

Browse files
committed
Add discussion of channels allowing simultaneous send/receive
1 parent 68f680b commit d2eb09c

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

trio/_abc.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,10 @@ async def send(self, value: SendType) -> None:
567567
trio.ClosedResourceError: if you previously closed this
568568
:class:`SendChannel` object, or if another task closes it while
569569
:meth:`send` is running.
570+
trio.BusyResourceError: some channels allow multiple tasks to call
571+
`send` at the same time, but others don't. If you try to call
572+
`send` simultaneously from multiple tasks on a channel that
573+
doesn't support it, then you can get `~trio.BusyResourceError`.
570574
571575
"""
572576

@@ -607,6 +611,10 @@ async def receive(self) -> ReceiveType:
607611
:class:`ReceiveChannel` object.
608612
trio.BrokenResourceError: if something has gone wrong, and the
609613
channel is broken.
614+
trio.BusyResourceError: some channels allow multiple tasks to call
615+
`receive` at the same time, but others don't. If you try to call
616+
`receive` simultaneously from multiple tasks on a channel that
617+
doesn't support it, then you can get `~trio.BusyResourceError`.
610618
611619
"""
612620

trio/_channel.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,9 @@ def send_nowait(self, value):
147147

148148
@enable_ki_protection
149149
async def send(self, value):
150-
"""See `~trio.abc.SendChannel.send`.
150+
"""See `SendChannel.send <trio.abc.SendChannel.send>`.
151+
152+
Memory channels allow multiple tasks to call `send` at the same time.
151153
152154
"""
153155
await trio.hazmat.checkpoint_if_cancelled()
@@ -259,7 +261,11 @@ def receive_nowait(self):
259261

260262
@enable_ki_protection
261263
async def receive(self):
262-
"""See `~trio.abc.ReceiveChannel.receive`.
264+
"""See `ReceiveChannel.receive <trio.abc.ReceiveChannel.receive>`.
265+
266+
Memory channels allow multiple tasks to call `receive` at the same
267+
time. The first task will get the first item sent, the second task
268+
will get the second item sent, and so on.
263269
264270
"""
265271
await trio.hazmat.checkpoint_if_cancelled()

0 commit comments

Comments
 (0)