{"record":{"id":"68986372e828c920","repo":"ATH-MaaS/Pixelle-Video","slug":"seedance-task-id-task-id","errorCode":null,"errorMessage":"Seedance 视频生成超时 (task_id={task_id})","messagePattern":"Seedance 视频生成超时 \\(task_id=(.+?)\\)","errorType":"exception","errorClass":"TimeoutError","httpStatus":null,"severity":"error","filePath":"pixelle_video/services/api_services/video_seedance.py","lineNumber":167,"sourceCode":"            resp = requests.get(url, headers=self._headers(), timeout=30, proxies=self._proxies())\n            resp.raise_for_status()\n            data = resp.json()\n            \n            status = data.get(\"status\")\n            if status == \"succeeded\":\n                # 根据实际返回体，URL 位于 content.video_url 或 video_url\n                video_url = data.get(\"content\", {}).get(\"video_url\") or data.get(\"video_url\")\n                if not video_url:\n                    raise RuntimeError(f\"Seedance 任务成功但未返回视频 URL: {data}\")\n                return video_url\n            elif status in (\"failed\", \"expired\"):\n                error_msg = data.get(\"error\", {}).get(\"message\") or data.get(\"status_msg\") or \"未知错误\"\n                raise RuntimeError(f\"Seedance 视频生成{status}: {error_msg}\")\n            \n            logger.debug(f\"SeedanceVideoClient: 任务进行中 {task_id}, status={status}, poll={i+1}\")\n            time.sleep(interval)\n            \n        raise TimeoutError(f\"Seedance 视频生成超时 (task_id={task_id})\")\n\n    def _download_video(self, url: str, save_path: str):\n        os.makedirs(os.path.dirname(save_path), exist_ok=True)\n        resp = requests.get(url, stream=True, timeout=120, proxies=self._proxies())\n        resp.raise_for_status()\n        with open(save_path, \"wb\") as f:\n            for chunk in resp.iter_content(chunk_size=8192):\n                if chunk:\n                    f.write(chunk)\n        logger.info(f\"SeedanceVideoClient: 视频已保存: {save_path}\")\n\nif __name__ == \"__main__\":\n    import sys\n    sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))\n    from config import Config\n\n    logging.basicConfig(level=logging.INFO, format=\"%(asctime)s %(levelname)s %(message)s\")\n","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/ATH-MaaS/Pixelle-Video/blob/848b054e4fae40dabc62ec58e960b573e83793ac/pixelle_video/services/api_services/video_seedance.py#L149-L185","documentation":"_poll_until_done raises TimeoutError after exhausting max_polls (default 120) polling attempts at interval seconds (default 5) without the task reaching 'succeeded' or 'failed'. The task is still pending server-side when the client gives up.","triggerScenarios":"generate_video submits a task whose generation takes longer than max_polls*interval (default 10 minutes) — typical with long durations, high resolution, or peak-time queueing.","commonSituations":"Long-duration/high-res generation; service degraded/slow queue; interval too aggressive causing throttle responses that never advance status; task silently stuck in 'running'.","solutions":["Increase the polling budget via _poll_until_done(task_id, max_polls=..., interval=...) or expose it through generate_video kwargs","Then poll the task ID manually — the exception includes task_id, and the task may still finish later","Increase the interval (e.g. 10s) to reduce API pressure on long jobs","Check service status for Seedance/Ark outages before retrying"],"exampleFix":"// before\nvideo_url = self._poll_until_done(task_id)\n// after\nvideo_url = self._poll_until_done(task_id, max_polls=360, interval=10)","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    video = client.generate_video(prompt=p, image_path=img, save_path=out)\nexcept TimeoutError as e:\n    task_id = str(e).split(\"task_id=\")[-1].rstrip(\")\")\n    logging.warning(f\"Generation still running; resume polling {task_id} manually\")\n    # continue polling via the task-query endpoint instead of resubmitting","preventionTips":["Size max_polls*interval generously for your worst-case duration/resolution","On timeout, keep polling the existing task_id rather than resubmitting (avoids double billing)","Alert on service status for Ark/Seedance during degraded-queue periods"],"tags":["timeout","polling","seedance","video-generation"],"backgroundTag":"polling-timeout","analyzedSha":"848b054e4fae40dabc62ec58e960b573e83793ac","analyzedAt":"2026-08-30T03:24:41.468Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}