File tree Expand file tree Collapse file tree 1 file changed +14
-7
lines changed
Expand file tree Collapse file tree 1 file changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -26,15 +26,22 @@ async def print_output_changes() -> None:
2626 async for output_id , active in output_changes :
2727 print (f"Output { output_id } changed to { active } " )
2828
29+ tasks = [
30+ asyncio .create_task (client .keepalive ()),
31+ asyncio .create_task (print_events ()),
32+ asyncio .create_task (print_state_changes ()),
33+ asyncio .create_task (print_zone_changes ()),
34+ asyncio .create_task (print_output_changes ()),
35+ ]
36+
2937 try :
30- await asyncio .gather (
31- client .keepalive (),
32- print_events (),
33- print_state_changes (),
34- print_zone_changes (),
35- print_output_changes (),
36- )
38+ # Allow handlers to start, then request an initial state update.
39+ await asyncio .sleep (0 )
40+ await client .update ()
41+ await asyncio .gather (* tasks )
3742 finally :
43+ for t in tasks :
44+ t .cancel ()
3845 await events .aclose ()
3946 await state_changes .aclose ()
4047 await zone_changes .aclose ()
You can’t perform that action at this time.
0 commit comments