Cancel queued Sume jobs after queue_full; handle 409 already started

How to free capacity after a 429 queue_full: cancel queued jobs, read job_generation_already_started on running ones, and why a cancel releases the reserve.

3 min readSume
All posts

Cancel a Sume job with POST /v1/jobs/{id}/cancel; it works only before generation starts. A queued job cancels and releases its reserve, a job already in generation answers 409 job_generation_already_started with details.cancelable: false, and a cancel of an already canceled job simply returns it again.

This is the tool to reach for after 429 queue_full: the docs tell you to wait for a terminal job or cancel queued work you no longer need, then retry the rejected submit with the same idempotency key.

A cancel helper

Run it over the job ids you stored when you submitted; the API only lets the member who created a job cancel it.

import os, requests

API = "https://api.sume.com"
H = {"Authorization": "Bearer " + os.environ["SUME_API_KEY"]}

def cancel(job_id):
    r = requests.post(API + "/v1/jobs/%s/cancel" % job_id, headers=H, timeout=30)
    if r.status_code == 409:
        code = r.json()["error"]["code"]
        return "running" if code == "job_generation_already_started" else code
    r.raise_for_status()
    return "canceled"

stale = ["job_aaa", "job_bbb", "job_ccc"]  # ids saved at submit
for job_id in stale:
    print(job_id, cancel(job_id))

Outcomes

Sume docs, read 2026-10-08
Job state at cancelResponseBilling
queuedCanceledReserve released
processing, provider work started409 job_generation_already_startedRuns to its end; success captures
Already canceledSame canceled job (idempotent)No change
completed or failedNot cancelableAlready settled

Cancel is not a throttle

Prefer to avoid queue_full by keeping submissions inside your accepted capacity. Cancel stays for work that became unnecessary, such as a campaign that changed after you submitted it.

A recovery routine after queue_full

When a submit returns queue_full, the efficient response is a short routine rather than a retry loop. List the ids you have in flight, check which are still queued, cancel the ones you no longer want, and wait for the rest. Then resend the rejected submit with the same key. Because cancel is idempotent, running the routine twice is harmless.

  • Record the job id at submit time; it is the only handle you have to cancel.
  • Treat 409 job_generation_already_started as normal, not as an error to alert on.
  • Only the member who created a job can cancel it, so a shared worker should use one key per owner.

Sources

Related posts

More in Developers

All Developers posts

Written by Sume