File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed
custom_components/pyscript Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -175,12 +175,10 @@ async def start_triggers(event):
175
175
176
176
async def stop_triggers (event ):
177
177
_LOGGER .debug ("stopping triggers" )
178
- for global_ctx_name , global_ctx in GlobalContextMgr .items ():
179
- if not global_ctx_name .startswith ("file." ):
180
- continue
178
+ for _ , global_ctx in GlobalContextMgr .items ():
181
179
global_ctx .stop ()
182
180
# tell reaper task to exit (after other tasks are cancelled)
183
- Function .task_cancel ( None )
181
+ await Function .reaper_stop ( )
184
182
185
183
hass .bus .async_listen (EVENT_HOMEASSISTANT_STARTED , start_triggers )
186
184
hass .bus .async_listen (EVENT_HOMEASSISTANT_STOP , stop_triggers )
Original file line number Diff line number Diff line change @@ -92,6 +92,12 @@ async def task_cancel_reaper(reaper_q):
92
92
cls .task_reaper_q = asyncio .Queue (0 )
93
93
cls .task_cancel_repeaer = Function .create_task (task_cancel_reaper (cls .task_reaper_q ))
94
94
95
+ @classmethod
96
+ async def reaper_stop (cls ):
97
+ """Tell the reaper task to exit by sending a special task None."""
98
+ cls .task_cancel (None )
99
+ await cls .task_cancel_repeaer
100
+
95
101
@classmethod
96
102
async def async_sleep (cls , duration ):
97
103
"""Implement task.sleep()."""
You can’t perform that action at this time.
0 commit comments