From 88039fb750f16547d78caf38d4e1c524a2524510 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Thu, 25 Jun 2026 12:18:20 +0400 Subject: [PATCH] =?UTF-8?q?v1.0.178:=20classify-batch=20=E2=86=92=20async?= =?UTF-8?q?=20(202=20Accepted=20+=20background=20thread).=20=D0=9F=D1=80?= =?UTF-8?q?=D0=B8=2069=20=D1=84=D0=B0=D0=B9=D0=BB=D0=B0=D1=85=20=D0=91?= =?UTF-8?q?=D0=94=20=D0=B7=D0=B0=D0=B4=D1=8B=D1=85=D0=B0=D0=B5=D1=82=D1=81?= =?UTF-8?q?=D1=8F.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/convert_server.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/deploy/convert_server.py b/deploy/convert_server.py index 568a4a3..973cf8c 100755 --- a/deploy/convert_server.py +++ b/deploy/convert_server.py @@ -241,8 +241,18 @@ class Handler(BaseHTTPRequestHandler): self._json({"ok": False, "error": "batch_id required"}, 400) return from services.classify import classify_batch - result = classify_batch(batch_id) - self._json(result) + from db import documents as db_docs + import threading + + # Посчитать сколько файлов — ответить сразу, классифицировать в фоне + pending = db_docs.list_pending(batch_id) + total = len(pending) + if total == 0: + self._json({"ok": False, "error": "no pending documents"}, 400) + return + + threading.Thread(target=classify_batch, args=(batch_id,), daemon=True).start() + self._json({"ok": True, "total": total}, 202) # ── POST /apply-groups ───────────────────────────────────────────────