0.23.0 added add_many and replace_many, which let callers schedule a batch of tasks in pipelined round-trips. There's no batch equivalent for cancel, so code that reconciles a group of scheduled tasks can batch the add/replace side but still pays one round-trip per key when cancelling.
Concrete case: Prefect Cloud's automation change-stream consumers reconcile an automation's scheduled trigger evaluations against its current state. When an automation is enabled/edited we replace_many its triggers' evaluations in one round-trip, but when it's disabled we loop await docket.cancel(key) per trigger.
A cancel_many(keys: Iterable[str], *, chunk_size: int | None = 1000) mirroring the other batch methods (per-key semantics unchanged, pipelined chunks, no cross-batch atomicity) would round this out.
0.23.0 added
add_manyandreplace_many, which let callers schedule a batch of tasks in pipelined round-trips. There's no batch equivalent forcancel, so code that reconciles a group of scheduled tasks can batch the add/replace side but still pays one round-trip per key when cancelling.Concrete case: Prefect Cloud's automation change-stream consumers reconcile an automation's scheduled trigger evaluations against its current state. When an automation is enabled/edited we
replace_manyits triggers' evaluations in one round-trip, but when it's disabled we loopawait docket.cancel(key)per trigger.A
cancel_many(keys: Iterable[str], *, chunk_size: int | None = 1000)mirroring the other batch methods (per-key semantics unchanged, pipelined chunks, no cross-batch atomicity) would round this out.