mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-09-30 11:12:35 +02:00
check_queue awaited asyncio.gather() over the whole selected batch before returning, so the scheduler run loop was blocked until the slowest FTP upload in the batch finished. On a large farm a 513s upload left 15 of 16 configured upload slots idle for 8.5 minutes while other printers came free — the setting behaved as a per-batch cap, not a worker pool. Launch uploads as independent background tasks tracked in a _inflight pool. Each tick excludes in-flight item rows and their printers from selection, launches at most limit - len(_inflight) new uploads, and returns immediately, so a freed slot refills on the next fast tick. The no-double- dispatch invariant the batch-await provided (rows stay pending until upload completes) is now carried by the in-flight exclusion; the pending->printing CAS, busy-printer guard (#2598), per-printer hold, auto-drying exclusion, and per-item failure isolation are all preserved per task. Rewrites the concurrent-dispatch tests around pool/reservation/refill semantics and adds coverage for slot refill, in-flight exclusion, and the non-blocking return.