Description
In app/tasks/download_tasks.py (~line 218), the download_video_task attempts to handle task failures by setting the video status to FAILED:
except Exception as exc:
logger.exception("Download failed for video %s", video_id)
# Mark as FAILED if we've exhausted retries
try:
video = db.get(Video, video_id)
if video and self.request.retries >= self.max_retries:
video.status = "FAILED"
db.commit()
However, if an exception occurs that is not included in autoretry_for=(RuntimeError,) (such as a database error, missing file, or JSON parsing failure), the task crashes immediately on the first attempt where self.request.retries is 0.
Since 0 >= 3 is false, the status is never updated to FAILED. The task dies, and the video is permanently stuck in the DOWNLOADING state, locking up the UI.
Suggested Fix
Modify the exception block to mark the video as FAILED if the retry limit is exhausted OR if the exception being caught is not retryable (i.e. this is the final terminal failure).
File Path
app/tasks/download_tasks.py
Description
In
app/tasks/download_tasks.py(~line 218), thedownload_video_taskattempts to handle task failures by setting the video status toFAILED:However, if an exception occurs that is not included in
autoretry_for=(RuntimeError,)(such as a database error, missing file, or JSON parsing failure), the task crashes immediately on the first attempt whereself.request.retriesis0.Since
0 >= 3is false, the status is never updated toFAILED. The task dies, and the video is permanently stuck in theDOWNLOADINGstate, locking up the UI.Suggested Fix
Modify the exception block to mark the video as
FAILEDif the retry limit is exhausted OR if the exception being caught is not retryable (i.e. this is the final terminal failure).File Path
app/tasks/download_tasks.py