{"record":{"id":"2787e9e52a15be21","repo":"unslothai/unsloth","slug":"sd-server-job-queue-is-full-http-429","errorCode":null,"errorMessage":"sd-server job queue is full (HTTP 429).","messagePattern":"sd-server job queue is full \\(HTTP 429\\)\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":429,"severity":"warning","filePath":"studio/backend/core/inference/sd_cpp_server.py","lineNumber":466,"sourceCode":"        \"\"\"\n        # Already stopped with the cancel event set: report cancellation (route 409), not a generic \"server died\" 500.\n        if self._stopped or not self.is_alive():\n            if cancel_event is not None and cancel_event.is_set():\n                raise SdCppCancelled(\"sd-server generation was cancelled.\")\n            raise RuntimeError(\"sd-server is not running.\")\n\n        self._step_listener = on_step\n        job_id: Optional[str] = None\n        try:\n            # Submit -> 202 Accepted + job id.\n            try:\n                resp = self._client.post(\n                    f\"{self.base_url}{_IMG_GEN_PATH}\", json = payload, timeout = submit_timeout\n                )\n            except (*_TRANSPORT_ERRORS, httpx.TimeoutException) as exc:\n                raise RuntimeError(self._died_message(\"img_gen submit\", exc)) from exc\n            if resp.status_code == 429:\n                raise RuntimeError(\"sd-server job queue is full (HTTP 429).\")\n            if resp.status_code not in (200, 202):\n                raise RuntimeError(\n                    f\"sd-server img_gen submit -> {resp.status_code}: {resp.text[:500]}\"\n                )\n            try:\n                job = resp.json()\n            except ValueError as exc:\n                raise RuntimeError(\n                    f\"sd-server img_gen returned a non-JSON submit response: {exc}\"\n                ) from exc\n            if not isinstance(job, dict):\n                raise RuntimeError(\n                    f\"sd-server img_gen returned an unexpected submit response type: {type(job)}\"\n                )\n            job_id = job.get(\"id\")\n            if not job_id:\n                raise RuntimeError(f\"sd-server img_gen returned no job id: {job}\")\n","sourceCodeStart":448,"sourceCodeEnd":484,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/core/inference/sd_cpp_server.py#L448-L484","documentation":"The sd-server answered the img_gen submit with HTTP 429, meaning its internal job queue is full. This is backpressure, not a failure: the server intentionally caps concurrent queued jobs and tells the client to stop flooding it. The wrapper surfaces it distinctly so callers can throttle instead of treating it as a dead server.","triggerScenarios":"Submitting more concurrent img_gen jobs than the server's queue capacity while earlier jobs are still running — parallel batch fan-out from multiple threads or clients.","commonSituations":"A UI firing several generations at once; an automation script without a concurrency limiter; long-running jobs backing up the queue.","solutions":["Wait for in-flight jobs to finish, then resubmit; respect 429 as a signal to throttle.","Cap client-side concurrency to the server's queue size (or 1) with a semaphore.","Batch multiple images into a single job (batch count) instead of many submitted jobs."],"exampleFix":"# before\nfor prompt in prompts:\n    threading.Thread(target=server.img_gen, args=(payload(prompt),)).start()\n# after\nsem = threading.Semaphore(1)\ndef gen(p):\n    with sem:\n        server.img_gen(payload(p))","handlingStrategy":"retry","validationCode":"sem = threading.Semaphore(1)  # cap concurrent submits at the queue capacity\n# with sem: server.img_gen(...)","typeGuard":null,"tryCatchPattern":"try:\n    blobs = server.img_gen(payload, ...)\nexcept RuntimeError as e:\n    if \"queue is full\" in str(e):\n        time.sleep(2); blobs = server.img_gen(payload, ...)\n    raise","preventionTips":["Limit client-side generation concurrency with a semaphore.","Batch several images into one job instead of many submits.","Treat 429 as backpressure: back off, don't hammer."],"tags":["diffusion","sd-cpp","server","rate-limit","backpressure"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}