Fix worker db

This commit is contained in:
2026-09-29 05:39:45 +00:00
parent 73c51ed1cd
commit 498a22ab61
8 changed files with 241 additions and 43 deletions

View File

@@ -249,9 +249,12 @@ class Worker:
self.callback(job)
return True
def loop(self, step):
def loop(self, step, monitor_threads=()):
"""Lỗi tạm thời (SQLite locked, HDFS chập chờn) chỉ log rồi thử lại, không được giết luồng."""
while not self.stop.is_set():
dead = [thread.name for thread in monitor_threads if not thread.is_alive()]
if dead:
raise RuntimeError(f"Worker threads stopped unexpectedly: {', '.join(dead)}")
try:
if step():
continue
@@ -281,7 +284,7 @@ class Worker:
log.info("Worker started with %s OCR threads and %s callback threads",
self.settings.ocr_workers, self.settings.callback_workers)
try:
self.loop(self.coordinator_once)
self.loop(self.coordinator_once, threads)
finally:
self.stop.set()
for thread in threads: