Skip to content

Add cancel_many to complete the batch scheduling API #446

Description

@chrisguidry

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions