From 3176ebf102c64234acb677ba80fecf92b6884086 Mon Sep 17 00:00:00 2001 From: salvacybersec Date: Tue, 7 Apr 2026 00:33:35 +0300 Subject: [PATCH] =?UTF-8?q?Fix=20batch=20size=20(20=E2=86=925)=20and=20scr?= =?UTF-8?q?ipt=20detection=20in=20monitor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Reduce embed batch to 5 — AnythingLLM hangs on batches >10 - Fix check_script_running() to properly detect setup.py process (was returning false because pgrep matched monitor.py too) Co-Authored-By: Claude Opus 4.6 (1M context) --- monitor.py | 11 +++++++++-- setup.py | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/monitor.py b/monitor.py index 5c5f3ec..2f670af 100755 --- a/monitor.py +++ b/monitor.py @@ -85,8 +85,15 @@ def check_api(config): def check_script_running(): try: import subprocess - result = subprocess.run(["pgrep", "-f", "setup.py"], capture_output=True, text=True) - return result.returncode == 0 + result = subprocess.run( + ["pgrep", "-af", "setup.py"], + capture_output=True, text=True + ) + # Filter out monitor.py and grep itself + for line in result.stdout.strip().split("\n"): + if line and "monitor" not in line and "pgrep" not in line: + return True + return False except Exception: return None diff --git a/setup.py b/setup.py index 77363a9..ac9458e 100644 --- a/setup.py +++ b/setup.py @@ -532,8 +532,8 @@ def assign_to_workspaces(config, persona_folders, progress, batch_size, delay): log.info(f"[{idx}/{total_personas}] → {codename} ({slug}): {len(new_docs)} docs to embed") - # Use smaller batches for embedding (10-20 is safer than 50) - embed_batch = min(batch_size, 20) + # Use small batches for embedding — AnythingLLM hangs on large batches + embed_batch = min(batch_size, 5) persona_ok = 0 persona_fail = 0