Fix worker db
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user