Skip to content

Commit

Permalink
Add timeout for Kickstart flash reading
Browse files Browse the repository at this point in the history
  • Loading branch information
kuba2k2 committed Nov 4, 2023
1 parent 7c0c948 commit 88a5786
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ltctplugin/upk2esphome/work.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def run_url(self, url: str):
start = 0x1E0000 - offset
end = 0x200000 - offset
init_size = 1024
block_size = 4096
block_size = 2048
buffer = bytearray(end - start)

with ClickProgressCallback(length=end - start) as bar:
Expand All @@ -66,7 +66,7 @@ def run_url(self, url: str):
params = dict(offset=0, length=init_size)

bar.on_message(f"Connecting to {ip}...")
with requests.get(url, params) as r:
with requests.get(url, params, timeout=5.0) as r:
data = r.content
if len(data) != init_size:
self.on_error(
Expand All @@ -81,7 +81,7 @@ def run_url(self, url: str):
params["offset"] = offset + start
params["length"] = read_size
sleep(0.05)
with requests.get(url, params) as r:
with requests.get(url, params, timeout=5.0) as r:
data = r.content
if len(data) != read_size:
warning(f"Incomplete response read: {len(data)}/{read_size}")
Expand Down

0 comments on commit 88a5786

Please sign in to comment.