idle-draft: fill all free worker slots, not one per completion
try_submit() returned after a single submission and was only called at startup and once per completion, capping real concurrency at 1 task regardless of the parallel setting — the ThreadPoolExecutor pool was sized but never filled. Loop until every free slot is filled or no eligible candidate remains, per spec §10 (wording sharpened to make the whole-pool semantics explicit). No stub-claude harness exists yet to test dispatch concurrency end-to-end; verified live against the real queue (36 candidates, parallel=20). Claude-Session: https://claude.ai/code/session_01Lgv4Qn82boNFC1jn8QXSNw
This commit is contained in:
@@ -1369,23 +1369,26 @@ def run_dispatch(args, config: dict, repo: Path, state_path: Path) -> int:
|
||||
|
||||
def try_submit():
|
||||
nonlocal dispatched_count
|
||||
if args.once and dispatched_count >= 1:
|
||||
return
|
||||
nonlocal queue
|
||||
queue = build_ready_queue(repo, config, state, in_flight)
|
||||
for cand in queue:
|
||||
provider, _ = select_provider(cand["work_type"], config, gates, credential_ok)
|
||||
if provider is None:
|
||||
continue
|
||||
cand = dict(cand)
|
||||
cand["provider"] = provider
|
||||
cand["before_pct"] = gates.get(provider, {}).get("seven_day_pct")
|
||||
in_flight.add(cand["item_key"])
|
||||
dispatched_count += 1
|
||||
log_event(repo, f"dispatch: {cand['item_key']} work_type={cand['work_type']} provider={provider}")
|
||||
fut = executor.submit(run_task, repo, config, cand, defaults["max_turns"], defaults["task_timeout"])
|
||||
futures[fut] = cand
|
||||
return
|
||||
while len(futures) < max(1, parallel):
|
||||
if args.once and dispatched_count >= 1:
|
||||
return
|
||||
queue = build_ready_queue(repo, config, state, in_flight)
|
||||
for cand in queue:
|
||||
provider, _ = select_provider(cand["work_type"], config, gates, credential_ok)
|
||||
if provider is None:
|
||||
continue
|
||||
cand = dict(cand)
|
||||
cand["provider"] = provider
|
||||
cand["before_pct"] = gates.get(provider, {}).get("seven_day_pct")
|
||||
in_flight.add(cand["item_key"])
|
||||
dispatched_count += 1
|
||||
log_event(repo, f"dispatch: {cand['item_key']} work_type={cand['work_type']} provider={provider}")
|
||||
fut = executor.submit(run_task, repo, config, cand, defaults["max_turns"], defaults["task_timeout"])
|
||||
futures[fut] = cand
|
||||
break
|
||||
else:
|
||||
return
|
||||
|
||||
try_submit()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user