mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-24 05:41:40 +00:00
fix(kanban): cap dispatch by running workers
This commit is contained in:
parent
cede612987
commit
845be254ec
2 changed files with 60 additions and 1 deletions
|
|
@ -3660,6 +3660,14 @@ def dispatch_once(
|
|||
result.timed_out = enforce_max_runtime(conn)
|
||||
result.promoted = recompute_ready(conn)
|
||||
|
||||
running_count = 0
|
||||
if max_spawn is not None:
|
||||
running_count = int(
|
||||
conn.execute(
|
||||
"SELECT COUNT(*) FROM tasks WHERE status = 'running'"
|
||||
).fetchone()[0]
|
||||
)
|
||||
|
||||
ready_rows = conn.execute(
|
||||
"SELECT id, assignee FROM tasks "
|
||||
"WHERE status = 'ready' AND claim_lock IS NULL "
|
||||
|
|
@ -3667,7 +3675,7 @@ def dispatch_once(
|
|||
).fetchall()
|
||||
spawned = 0
|
||||
for row in ready_rows:
|
||||
if max_spawn is not None and spawned >= max_spawn:
|
||||
if max_spawn is not None and running_count + spawned >= max_spawn:
|
||||
break
|
||||
if not row["assignee"]:
|
||||
result.skipped_unassigned.append(row["id"])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue