Huey task that polls an AI video job with schedule(delay=...)

A Huey task reads Sume's job status once and reschedules itself with task.schedule(delay=...) from next_poll_after_seconds, so no worker thread sleeps.

4 min readSume
All posts

Huey is a small Python task queue, and polling a video render with it is two lines: call the task, and when the job is not terminal call poll.schedule(args=(job_id, n + 1), delay=wait). The task reads Sume's GET /v1/jobs/{id}/status once. terminal ends the chain, and next_poll_after_seconds provides the wait (Sume jobs guide, read 2026-10-06).

The clip in this example is MiniMax H3 at 768p for 6 seconds. Sume bills H3 768p at $0.075 per second, so the clip is $0.45.

What is the full module?

Run huey_consumer.py tasks.huey. Huey's retries option covers HTTP errors; the poll chain counts attempts itself.

import os
import requests
from huey import RedisHuey

huey = RedisHuey("clips")
API = "https://api.sume.com"
H = {"Authorization": f"Bearer {os.environ['SUME_API_KEY']}"}

@huey.task()
def submit(prompt: str, key: str):
    r = requests.post(f"{API}/v1/videos", timeout=30,
                      headers={**H, "Idempotency-Key": key},
                      json={"model": "minimax-h3", "prompt": prompt,
                            "duration": 6, "resolution": "768p"})
    r.raise_for_status()
    poll.schedule(args=(r.json()["id"], 0), delay=15)

@huey.task(retries=3, retry_delay=30)
def poll(job_id: str, n: int):
    r = requests.get(f"{API}/v1/jobs/{job_id}/status", headers=H, timeout=30)
    r.raise_for_status()
    s = r.json()
    if s["terminal"]:
        return s["sume_status"]
    if n < 120:
        poll.schedule(args=(job_id, n + 1),
                      delay=s.get("next_poll_after_seconds") or 15)

What does H3 cost at the other sizes?

Sume MiniMax H3 per-second rates (list x 1.25) and 6-second totals, from the Sume catalog, read 2026-10-06
OutputPer second6-second clip
480p$0.0625$0.375
768p$0.075$0.45
2K upscale$0.1625$0.975
4K upscale$0.20$1.20

Does a retry of the poller bill a second clip?

No, as long as the poller only reads. Keep the paid POST /v1/videos in a separate step with an Idempotency-Key you own, and let the poller use GET /v1/jobs/{id}/status. A client-side give-up never cancels the render; Sume's jobs guide says the job keeps running, so store the job id and read it again later instead of submitting a second time.

Sources

Related posts

More in Developers

All Developers posts

Written by Sume