Closed
Description
I've finally managed to get this boiled down and reproduceable.
- Install this code in a script:
@time_trigger('startup')
def test_startup():
task.unique('test_counter')
log.info('starting')
cnt = 0
while True:
cnt += 1
log.info(f'count {cnt}')
task.sleep(1)
@time_trigger('shutdown')
def test_shutdown():
task.unique('test_counter')
log.info('stopping')
- pyscript.reload to make it active. See it counting.
- save the file again to update mtime. pyscript.reload. See it counting again.
- repeat step 3 one more time. See the error below in logs.
2020-12-13 06:29:01 INFO (MainThread) [custom_components.pyscript.global_ctx] Reloaded /config/pyscript/shutdowntest.py
2020-12-13 06:29:01 INFO (MainThread) [custom_components.pyscript.file.shutdowntest.test_shutdown] stopping
2020-12-13 06:29:01 INFO (MainThread) [custom_components.pyscript.file.shutdowntest.test_startup] starting
2020-12-13 06:29:01 INFO (MainThread) [custom_components.pyscript.file.shutdowntest.test_startup] count 1
2020-12-13 06:29:01 ERROR (MainThread) [custom_components.pyscript.function] task_reaper: got exception Traceback (most recent call last):
File "/config/custom_components/pyscript/function.py", line 97, in task_reaper
await cmd[1]
RuntimeError: await wasn't used with future
2020-12-13 06:29:02 INFO (MainThread) [custom_components.pyscript.file.shutdowntest.test_startup] count 2
Once this error is produced, while the counter itself keeps counting, many other pyscript scripts stop triggering reliably as they usually do.
- Repeat step 3 again and you will now see there are two counters. The previous one didn't stop, but a new one started.
- Do it again and you now have three counters. etc, etc.
- To fix it, comment out the script added in step 1 and restart home assistant. (without restarting home assistant and just doing pyscript.reload, only the most recent counter is stopped)
Metadata
Metadata
Assignees
Labels
No labels