Skip to content

Commit cd87d2e

Browse files
committed
stop the reaper task too on EVENT_HOMEASSISTANT_STOP
1 parent 01d752d commit cd87d2e

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

custom_components/pyscript/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@ async def stop_triggers(event):
179179
if not global_ctx_name.startswith("file."):
180180
continue
181181
global_ctx.stop()
182+
# tell reaper task to exit (after other tasks are cancelled)
183+
Function.task_cancel(None)
182184

183185
hass.bus.async_listen(EVENT_HOMEASSISTANT_STARTED, start_triggers)
184186
hass.bus.async_listen(EVENT_HOMEASSISTANT_STOP, stop_triggers)

custom_components/pyscript/function.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ async def task_cancel_reaper(reaper_q):
7878
try:
7979
try:
8080
task = await reaper_q.get()
81+
if task is None:
82+
return
8183
task.cancel()
8284
await task
8385
except asyncio.CancelledError:

0 commit comments

Comments
 (0)