{"record":{"id":"40fac5d6532ca81a","repo":"calesthio/OpenMontage","slug":"polling-prediction-prediction-id-failed-after-c","errorCode":null,"errorMessage":"Polling prediction {prediction_id} failed after {consecutive_transport_errors} consecutive transport errors: {exc}","messagePattern":"Polling prediction (.+?) failed after (.+?) consecutive transport errors: (.+?)","errorType":"exception","errorClass":"AtlasError","httpStatus":null,"severity":"error","filePath":"tools/atlas_client.py","lineNumber":153,"sourceCode":"\n    Raises AtlasError on reported failure or when `timeout` seconds elapse.\n    \"\"\"\n    import requests\n\n    url = f\"{PREDICTION_ENDPOINT}/{prediction_id}\"\n    elapsed = 0.0\n    last_status = \"unknown\"\n    consecutive_transport_errors = 0\n\n    while elapsed < timeout:\n        try:\n            response = requests.get(\n                url, headers=_headers(api_key, json_body=False), timeout=request_timeout\n            )\n        except Exception as exc:  # noqa: BLE001\n            consecutive_transport_errors += 1\n            if consecutive_transport_errors >= 5:\n                raise AtlasError(\n                    f\"Polling prediction {prediction_id} failed after \"\n                    f\"{consecutive_transport_errors} consecutive transport errors: {exc}\"\n                ) from exc\n            time.sleep(interval)\n            elapsed += interval\n            continue\n\n        _raise_for_status(response, f\"Atlas Cloud poll for {prediction_id}\")\n        consecutive_transport_errors = 0\n        data = _payload_of(response)\n        last_status = str(data.get(\"status\", \"unknown\")).lower()\n\n        if last_status in TERMINAL_SUCCESS:\n            outputs = data.get(\"outputs\") or []\n            if not outputs:\n                raise AtlasError(\n                    f\"Prediction {prediction_id} reported '{last_status}' but returned no outputs.\"\n                )","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/calesthio/OpenMontage/blob/95e1c3d0ab93482159818560f6a8c8e866b9139f/tools/atlas_client.py#L135-L171","documentation":"Raised inside the poll loop when five consecutive HTTP requests to fetch the prediction fail at the transport layer (exceptions from requests.get: timeouts, connection resets, DNS blips). A single transport error is tolerated with a sleep-and-retry; five in a row means the connection to Atlas is effectively down and polling aborts instead of burning the whole timeout silently.","triggerScenarios":"Long video generations (10+ minutes) polled every few seconds while the network drops (laptop sleep, Wi-Fi roam, VPN reconnect); a proxy going down mid-poll; request_timeout (default 30s) too small for slow poll responses, making each poll time out consecutively.","commonSituations":"Mobile/intermittent networks running long renders; VPN token expiring mid-job; Atlas endpoints briefly unreachable while the prediction itself continues server-side; aggressive NAT idle timeouts killing keep-alive connections.","solutions":["Check network stability to the Atlas host (the prediction itself may still be running — resubmit only a poll, not the generation, if you saved the prediction id)","Increase request_timeout if the exception is a ReadTimeout on each poll","Retry the poll() call with the same prediction_id after connectivity returns","For long jobs, poll less frequently (larger interval) to reduce exposure windows"],"exampleFix":"// before\ndata = atlas_client.poll(pid, api_key)\n\n// after — resume polling with the same id, longer per-request timeout\ndata = atlas_client.poll(pid, api_key, interval=5.0, request_timeout=60)","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    data = atlas_client.poll(pid, api_key, interval=5.0, request_timeout=60)\nexcept AtlasError as e:\n    if \"consecutive transport errors\" in str(e):\n        time.sleep(30)  # let connectivity recover\n        data = atlas_client.poll(pid, api_key, interval=5.0, request_timeout=60)  # same pid — no resubmit\n    else:\n        raise","preventionTips":["Persist the prediction id right after submit so polling can resume after network recovery","Use a longer request_timeout and interval for long video jobs to lower per-poll failure odds","Keep the process/network awake (disable sleep) during long polls"],"tags":["atlas-cloud","polling","network","retry","resilience"],"backgroundTag":null,"analyzedSha":"95e1c3d0ab93482159818560f6a8c8e866b9139f","analyzedAt":"2026-08-15T06:31:20.014Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}