Issue with task.executor and HA crashing #359
-
Hello, I've been working on a little script to keep up a Twitch stream on one of my TVs. This requires use of the requests module to interact with the Twitch API. I'm not super proficient in Python, but I think I've got the code right as I'm now locking up my HA installation instead of getting syntax errors. The issue now is when the script is running, HA becomes unresponsive until a core restart is issued or HA just crashes and restarts itself. The logs seem to be cleared on restart, so I'm having difficulty pinning down the issue. Any advice would be appreciated. The script:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The symptoms sound like something you are calling from pyscript is blocking, which will block the main HA thread. The obvious candidate is the Does the stalling of HA only happen after you call the The only other call that your function makes is service.call("media_extractor", "play_media", entity_id=entity_id, media_content_id=url, media_content_type="video") There are several more intuitive ways of calling a service - see the docs. If that doesn't help, I'd recommend. bisecting the function - remove code until it no longer blocks so you can figure out which part of the code is causing the problem. The first lines to remove are the service call to |
Beta Was this translation helpful? Give feedback.
The symptoms sound like something you are calling from pyscript is blocking, which will block the main HA thread. The obvious candidate is the
requests.get
, but you are correctly calling that viatask.executor
, so that shouldn't be the problem.Does the stalling of HA only happen after you call the
twitch_picker
service? Could there be an infinite loop with it being called repeatedly (ie, does a side-effect of calling it cause another trigger to call it)? The fact that HA actually crashes, rather than just slwoing down, suggests this could be the issue.The only other call that your function makes is
hass.services.call()
. That shouldn't block, but I'm not 100% sure. I'd recommend using th…