This PR adds a 15 second timeout to all API requests to Leviton. As per the requests lib docs, a call may hang indefinitely without a timeout. A timeout will improve the reliability of always-on applications of the decora_wifi lib.
Motivation
I use this library as part of homeassistant. I have found very rarely (once every 2 months or so) that the decora_wifi integration can break. Attaching a python debugger, I find a worker thread stuck indefinitely in the following stacktrace:
With this PR, I believe the flaky call_api() would timeout instead of getting stuck, and the following homeassistant update loop would hopefully succeed.
Implementation
15 seconds should surely be enough for any call. I looked if I could attach a timeout to the requests.Session, but that appears to not be possible.
Objective
This PR adds a 15 second timeout to all API requests to Leviton. As per the
requests
lib docs, a call may hang indefinitely without a timeout. A timeout will improve the reliability of always-on applications of the decora_wifi lib.Motivation
I use this library as part of homeassistant. I have found very rarely (once every 2 months or so) that the decora_wifi integration can break. Attaching a python debugger, I find a worker thread stuck indefinitely in the following stacktrace:
With this PR, I believe the flaky
call_api()
would timeout instead of getting stuck, and the following homeassistant update loop would hopefully succeed.Implementation
15 seconds should surely be enough for any call. I looked if I could attach a timeout to the
requests.Session
, but that appears to not be possible.