partially addresses #719
Showing 3 of 5 files from the diff.
trio/_channel.py
changed.
trio/tests/test_channel.py
changed.
Other files ignored by Codecov
newsfragments/1771.feature.rst
is new.
docs/source/reference-core.rst
has changed.
@@ -1,16 +1,24 @@
Loading
1 | 1 | from collections import deque, OrderedDict |
|
2 | 2 | from math import inf |
|
3 | + | from typing import NamedTuple |
|
3 | 4 | ||
4 | 5 | import attr |
|
5 | 6 | from outcome import Error, Value |
|
6 | 7 | ||
7 | - | from .abc import SendChannel, ReceiveChannel, Channel |
|
8 | + | from .abc import SendChannel, ReceiveChannel |
|
8 | 9 | from ._util import generic_function, NoPublicConstructor |
|
9 | 10 | ||
10 | 11 | import trio |
|
11 | 12 | from ._core import enable_ki_protection |
|
12 | 13 | ||
13 | 14 | ||
15 | + | class MemoryChannelPair(NamedTuple): |
|
16 | + | """Named tuple of send/receive memory channels""" |
|
17 | + | ||
18 | + | send_channel: "MemorySendChannel" |
|
19 | + | receive_channel: "MemoryReceiveChannel" |
|
20 | + | ||
21 | + | ||
14 | 22 | @generic_function |
|
15 | 23 | def open_memory_channel(max_buffer_size): |
|
16 | 24 | """Open a channel for passing objects between tasks within a process. |
@@ -40,9 +48,8 @@
Loading
40 | 48 | see :ref:`channel-buffering` for more details. If in doubt, use 0. |
|
41 | 49 | ||
42 | 50 | Returns: |
|
43 | - | A pair ``(send_channel, receive_channel)``. If you have |
|
44 | - | trouble remembering which order these go in, remember: data |
|
45 | - | flows from left → right. |
|
51 | + | A named tuple ``(send_channel, receive_channel)``. The tuple ordering is |
|
52 | + | intended to match the image of data flowing from left → right. |
|
46 | 53 | ||
47 | 54 | In addition to the standard channel methods, all memory channel objects |
|
48 | 55 | provide a ``statistics()`` method, which returns an object with the |
@@ -69,7 +76,7 @@
Loading
69 | 76 | if max_buffer_size < 0: |
|
70 | 77 | raise ValueError("max_buffer_size must be >= 0") |
|
71 | 78 | state = MemoryChannelState(max_buffer_size) |
|
72 | - | return ( |
|
79 | + | return MemoryChannelPair( |
|
73 | 80 | MemorySendChannel._create(state), |
|
74 | 81 | MemoryReceiveChannel._create(state), |
|
75 | 82 | ) |
@@ -19,7 +19,7 @@
Loading
19 | 19 | async def connect(self): |
|
20 | 20 | assert not self.closed |
|
21 | 21 | client, server = memory_stream_pair() |
|
22 | - | await self.queued_streams[0].send(server) |
|
22 | + | await self.queued_streams.send_channel.send(server) |
|
23 | 23 | return client |
|
24 | 24 | ||
25 | 25 | async def accept(self): |
@@ -27,7 +27,7 @@
Loading
27 | 27 | assert not self.closed |
|
28 | 28 | if self.accept_hook is not None: |
|
29 | 29 | await self.accept_hook() |
|
30 | - | stream = await self.queued_streams[1].receive() |
|
30 | + | stream = await self.queued_streams.receive_channel.receive() |
|
31 | 31 | self.accepted_streams.append(stream) |
|
32 | 32 | return stream |
|
33 | 33 |
Files | Coverage |
---|---|
trio | 99.64% |
Project Totals (114 files) | 99.64% |
pypy_nightly_py3.6
TRAVIS_OS_NAME=linux
linux-3.6.1
3.6.1=.6.1 TRAVIS_OS_NAME=linux
linux-3.7-dev
TRAVIS_OS_NAME=linux 3.7-dev=.7-dev
linux-3.6-dev
TRAVIS_OS_NAME=linux 3.6-dev=.6-dev
macOS (3.9.0-rc.2)
Windows (3.8, x64, with non-IFS LSP)
FreeBSD 12.1-RELEASE, full VM
TRAVIS_OS_NAME=
Fedora 32, full VM
TRAVIS_OS_NAME=
linux-3.9-dev
3.9-dev=.9-dev TRAVIS_OS_NAME=linux
linux-3.8-dev
3.8-dev=.8-dev TRAVIS_OS_NAME=linux
Ubuntu (3.8)
Ubuntu (3.7)
linux-3.9-dev
3.9-dev=.9-dev TRAVIS_OS_NAME=linux
Ubuntu (3.6)
Windows (3.8, x64)
Ubuntu (3.9.0-rc.2)
Windows (3.7, x64)
macOS (3.6)
Windows (3.8, x86)
Windows (3.6, x86)
Windows (3.8, x64, with Komodia LSP)
Windows (3.7, x86)
Windows (3.6, x64)
Windows (3.8, x64, with IFS LSP)
Windows (3.9.0-rc.2, x86)
Alpine
macOS (3.8)
Windows (3.9.0-rc.2, x64)
linux-pypy3.6-7.2.0
TRAVIS_OS_NAME=linux pypy3.6-7.2.0=.6-7.2.0
macOS (3.7)
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file.
The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files.
The size and color of each slice is representing the number of statements and the coverage, respectively.