File tree Expand file tree Collapse file tree 1 file changed +19
-6
lines changed
Expand file tree Collapse file tree 1 file changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -195,15 +195,22 @@ class and implement the abstract `_run()` method.
195195 any other more graceful way to stop the actor if you need to make sure it can't be
196196 interrupted at any `await` point.
197197
198- ## Example
198+ ### Examples
199199
200- Here's a simple example to demonstrate how to create two actors and connect
201- them.
200+ Here are a few simple but complete examples to demonstrate how to create create actors
201+ and connect them using [channels][frequenz.channels] .
202202
203- Please note the annotations in the code (like {{code_annotation_marker}}), they
204- explain step-by-step what's going on in order of execution.
203+ !!! tip
205204
206- ```python title="actors.py"
205+ The code examples are annotated with markers (like {{code_annotation_marker}}), they
206+ explain step-by-step what's going on in order of execution.
207+
208+ #### Composing actors
209+
210+ This example shows how to create two actors and connect them using
211+ [broadcast][frequenz.channels.Broadcast] channels.
212+
213+ ```python title="compose.py"
207214import asyncio
208215
209216from frequenz.channels import Broadcast, Receiver, Sender
@@ -306,6 +313,12 @@ async def main() -> None: # (2)!
30631311. The actors are stopped and cleaned up automatically when the `async with`
307314 block ends.
308315
316+ The expected output is:
317+
318+ ```
319+ Actor2 forwarding: "Actor1 forwarding: 'Hello'"
320+ ```
321+
309322[async context manager]: https://docs.python.org/3/reference/datamodel.html#async-context-managers
310323"""
311324
You can’t perform that action at this time.
0 commit comments