|
11 | 11 | iterators][typing.AsyncIterator], so the easiest way to receive values from them as |
12 | 12 | a stream is to use `async for`: |
13 | 13 |
|
14 | | -```python |
| 14 | +```python show_lines="6:" |
15 | 15 | from frequenz.channels import Anycast |
16 | 16 |
|
17 | 17 | channel = Anycast[int](name="test-channel") |
|
24 | 24 | If you need to receive values in different places or expecting a particular |
25 | 25 | sequence, you can use the [`receive()`][frequenz.channels.Receiver.receive] method: |
26 | 26 |
|
27 | | -```python |
| 27 | +```python show_lines="6:" |
28 | 28 | from frequenz.channels import Anycast |
29 | 29 |
|
30 | 30 | channel = Anycast[int](name="test-channel") |
|
42 | 42 | If you need to transform the received values, receivers provide a |
43 | 43 | [`map()`][frequenz.channels.Receiver.map] method to easily do so: |
44 | 44 |
|
45 | | -```python |
| 45 | +```python show_lines="6:" |
46 | 46 | from frequenz.channels import Anycast |
47 | 47 |
|
48 | 48 | channel = Anycast[int](name="test-channel") |
|
71 | 71 | closed), a [`ReceiverStoppedError`][frequenz.channels.ReceiverStoppedError] exception |
72 | 72 | is raised by [`receive()`][frequenz.channels.Receiver.receive] method. |
73 | 73 |
|
74 | | -```python |
| 74 | +```python show_lines="6:" |
75 | 75 | from frequenz.channels import Anycast |
76 | 76 |
|
77 | 77 | channel = Anycast[int](name="test-channel") |
|
88 | 88 | When used as an async iterator, the iteration will just stop without raising an |
89 | 89 | exception: |
90 | 90 |
|
91 | | -```python |
| 91 | +```python show_lines="6:" |
92 | 92 | from frequenz.channels import Anycast |
93 | 93 |
|
94 | 94 | channel = Anycast[int](name="test-channel") |
|
0 commit comments