From f0d278412f8c14e94a11678be424f6a6ddb79fa2 Mon Sep 17 00:00:00 2001 From: Moonyeah Date: Mon, 4 May 2026 14:38:43 +0800 Subject: [PATCH] feat(gateway): respect kanban.max_spawn config to limit concurrent tasks The dispatch_once function already accepts a max_spawn parameter but the gateway was calling it without passing any value, effectively ignoring the configuration. This change reads kanban.max_spawn from config.yaml and passes it through, allowing users to limit concurrent kanban tasks. This prevents resource exhaustion scenarios where kanban dispatcher spawns too many parallel workers on constrained hardware. --- gateway/run.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gateway/run.py b/gateway/run.py index 66c31c4382..22b8fbdb64 100644 --- a/gateway/run.py +++ b/gateway/run.py @@ -3623,6 +3623,11 @@ class GatewayRunner: if interval < 1.0: interval = 1.0 # sanity floor — tighter than this is a footgun + # Read max_spawn config to limit concurrent kanban tasks + max_spawn = kanban_cfg.get("max_spawn", None) + if max_spawn is not None: + logger.info(f"kanban dispatcher: max_spawn={max_spawn}") + # Initial delay so the gateway finishes wiring adapters before the # dispatcher spawns workers (those workers may hit gateway notify # subscriptions etc.). Matches the notifier watcher's delay. @@ -3651,7 +3656,7 @@ class GatewayRunner: _kb.init_db(board=slug) # idempotent, handles first-run except Exception: pass - return _kb.dispatch_once(conn, board=slug) + return _kb.dispatch_once(conn, board=slug, max_spawn=max_spawn) except Exception: logger.exception("kanban dispatcher: tick failed on board %s", slug) return None