UI: опрос задач переживает обрывы сети/перезапуск api
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -472,12 +472,11 @@ class MainView:
|
||||
|
||||
def _poll_loop(self):
|
||||
prev: dict = {}
|
||||
fails = 0
|
||||
try:
|
||||
while True:
|
||||
try:
|
||||
jobs = self.client.list_jobs()
|
||||
except (ApiError, Exception):
|
||||
break
|
||||
self._render_jobs(jobs)
|
||||
state = {j["id"]: (j["done_items"], j["status"]) for j in jobs}
|
||||
if state != prev:
|
||||
@@ -485,8 +484,14 @@ class MainView:
|
||||
self._refresh_library() # там же page.update()
|
||||
else:
|
||||
self.page.update()
|
||||
fails = 0
|
||||
if not any(j["status"] in ("queued", "running") for j in jobs):
|
||||
break
|
||||
except Exception:
|
||||
# обрыв сети/перезапуск api — не глушим опрос, пробуем ещё
|
||||
fails += 1
|
||||
if fails >= 10:
|
||||
break
|
||||
time.sleep(3)
|
||||
finally:
|
||||
self._polling = False
|
||||
|
||||
Reference in New Issue
Block a user