@@ -70,7 +70,7 @@ class communicates through message passing. Even when no particular message pass
7070### The `run()` Function
7171
7272The [`run()`][frequenz.sdk.actor.run] function can start many actors at once and waits
73- for them to finish. If any of the actors are stopped with errors, the errors will be
73+ for them to finish. If any of the actors is stopped with errors, the errors will be
7474logged.
7575
7676???+ example
@@ -85,13 +85,13 @@ async def _run(self) -> None:
8585 await run(MyActor()) # (1)!
8686 ```
8787
88- 1. This line will block until the actor is stopped.
88+ 1. This line will block until the actor completes its execution or is manually stopped.
8989
9090### Async Context Manager
9191
9292When an actor is used as an [async context manager], it is started when the
9393`async with` block is entered and stopped automatically when the block is exited
94- (even if an exception is raised).
94+ (even if an unhandled exception is raised).
9595
9696???+ example
9797
@@ -116,7 +116,7 @@ async def _run(self) -> None:
116116
117117When using the [`start()`][frequenz.sdk.actor.Actor.start] method, the actor is
118118started in the background and the method returns immediately. The actor will
119- continue to run until it is **manually** stopped.
119+ continue to run until it is **manually** stopped or until it completes its execution .
120120
121121???+ example
122122
@@ -203,8 +203,8 @@ def __init__(
203203 logs.
204204 5. We call [`Actor.__init__()`][frequenz.sdk.actor.Actor.__init__] to make sure the
205205 actor is properly initialized.
206- 6. We store the `input` argument in a *private* instance variable to use it later.
207- 7. We store the `output` argument in a *private* instance variable to use it later.
206+ 6. We store the `input` argument in a *private* attribute to use it later.
207+ 7. We store the `output` argument in a *private* attribute to use it later.
208208
209209### The `_run()` Method
210210
@@ -216,6 +216,8 @@ def __init__(
216216in the `_run()` method, typically receiving messages from one or more channels
217217([receivers][frequenz.channels.Receiver]), processing them and sending the results to
218218other channels ([senders][frequenz.channels.Sender]).
219+ However, it is worth noting that an actor can also be designed for a one-time execution
220+ or a limited number of runs, terminating upon completion.
219221
220222???+ example "Example echo actor"
221223
@@ -383,7 +385,7 @@ async def main() -> None: # (2)!
383385
384386 async with ( # (5)!
385387 Actor1(input_channel.new_receiver(), middle_channel.new_sender(), "actor1"),
386- Actor2(middle_channel.new_receiver(), output_channel.new_sender(), "actor1 "),
388+ Actor2(middle_channel.new_receiver(), output_channel.new_sender(), "actor2 "),
387389 ):
388390 await input_sender.send("Hello") # (6)!
389391 msg = await output_receiver.receive() # (7)!
@@ -397,7 +399,7 @@ async def main() -> None: # (2)!
3973991. We define 2 actors: `Actor1` and `Actor2` that will just forward a message
398400 from an input channel to an output channel, adding some text.
399401
400- 2. We define an async `main()` function with the main logic of our [asyncio][] program.
402+ 2. We define an async `main()` function within the main logic of our [asyncio][] program.
401403
4024043. We start the `main()` function in the async loop using [`asyncio.run()`][asyncio.run].
403405
@@ -525,8 +527,8 @@ async def main() -> None: # (6)!
525527 them to another channel.
526528
5275292. We implement the [`_run()`][_run] method that will receive messages from the two
528- channels using and send them to the output channel. The `run()` method will stop if
529- a `False` message is received.
530+ channels using [`select()`][frequenz.channels.util.select] and send them to the
531+ output channel. The `run()` method will stop if a `False` message is received.
530532
5315333. We create the channels that will be used with the actor.
532534
@@ -556,8 +558,7 @@ async def main() -> None: # (6)!
556558 message, so `"Received from receiver_1: True"` will be printed and `True` will be
557559 sent to the `output` channel.
558560
559- 12. Since `selected.value` is `True`, the loop will continue, going back to the and the
560- the loop will continue, going back to the
561+ 12. Since `selected.value` is `True`, the loop will continue, going back to the
561562 [`select()`][frequenz.channels.util.select] function.
562563
56356413. The [`selected_from()`][frequenz.channels.util.selected_from] function will return
0 commit comments