@@ -21,7 +21,7 @@ The [`Dispatcher` class](https://frequenz-floss.github.io/frequenz-dispatch-pyth
2121
2222``` python
2323import os
24- from frequenz.dispatch import Dispatcher, RunningState
24+ from frequenz.dispatch import Dispatcher
2525from unittest.mock import MagicMock
2626
2727async def run ():
@@ -42,29 +42,29 @@ async def run():
4242 changed_running_status_rx = dispatcher.running_status_change.new_receiver()
4343
4444 async for dispatch in changed_running_status_rx:
45- match dispatch.running( " DEMO_TYPE " ) :
46- case RunningState. RUNNING :
47- print ( f " Executing dispatch { dispatch.id } , due on { dispatch.start_time } " )
48- if actor.is_running :
49- actor.reconfigure(
50- components = dispatch.target,
51- run_parameters = dispatch.payload, # custom actor parameters
52- dry_run = dispatch.dry_run ,
53- until = dispatch.until,
54- ) # this will reconfigure the actor
55- else :
56- # this will start a new actor with the given components
57- # and run it for the duration of the dispatch
58- actor.start(
59- components = dispatch.target,
60- run_parameters = dispatch.payload, # custom actor parameters
61- dry_run = dispatch.dry_run ,
62- until = dispatch.until,
63- )
64- case RunningState. STOPPED :
65- actor.stop() # this will stop the actor
66- case RunningState. DIFFERENT_TYPE :
67- pass # dispatch not for this type
45+ if dispatch.type != " MY_TYPE " :
46+ continue
47+
48+ if dispatch.started :
49+ print ( f " Executing dispatch { dispatch.id } , due on { dispatch.start_time } " )
50+ if actor.is_running:
51+ actor.reconfigure(
52+ components = dispatch.target ,
53+ run_parameters = dispatch.payload, # custom actor parameters
54+ dry_run = dispatch.dry_run,
55+ until = dispatch.until,
56+ ) # this will reconfigure the actor
57+ else :
58+ # this will start a new actor with the given components
59+ # and run it for the duration of the dispatch
60+ actor.start(
61+ components = dispatch.target ,
62+ run_parameters = dispatch.payload, # custom actor parameters
63+ dry_run = dispatch.dry_run,
64+ until = dispatch.until,
65+ )
66+ else :
67+ actor.stop() # this will stop the actor
6868```
6969
7070## Supported Platforms
0 commit comments