Skip to content

Commit fdcad07

Browse files
fix: add timeout=30 to requests.get() in futurerate.py and octopus.py to prevent silent TCP stalls from hanging the main loop indefinitely
Fixes #4525 - a stalled Nord Pool connection would block the main prediction loop forever. With timeout=30, the existing exception handler will catch requests.exceptions.Timeout and fall back to cached rates via the existing retry logic. Also adds timeout to octopus.py download_octopus_free_func() which had the same pattern. Co-authored-by: springfall2008 <48591903+springfall2008@users.noreply.github.com>
1 parent 075f152 commit fdcad07

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

apps/predbat/futurerate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ def download_futurerate_data(self, url):
412412

413413
def download_futurerate_data_func(self, url):
414414
try:
415-
r = requests.get(url)
415+
r = requests.get(url, timeout=30)
416416
except Exception as e:
417417
self.log("Warn: Error downloading futurerate data from URL {}, request exception {}".format(url, e))
418418
self.record_status("Warn: Error downloading futurerate data from cloud", debug=url, had_errors=True)

apps/predbat/octopus.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2066,7 +2066,7 @@ def download_octopus_free_func(self, url):
20662066
Download octopus free session data directly from a URL, no caching.
20672067
"""
20682068
try:
2069-
r = requests.get(url)
2069+
r = requests.get(url, timeout=30)
20702070
except requests.exceptions.ConnectionError:
20712071
self.log("Warn: Octopus: Unable to download Octopus data from URL {} (ConnectionError)".format(url))
20722072
self.record_status("Warn: Unable to download Octopus free session data", debug=url, had_errors=True)

0 commit comments

Comments
 (0)