Fixes #19806: Introduce JobFailed exception to allow marking background jobs as failed (#19807)

This commit is contained in:
Jeremy Stretch
2025-07-02 15:02:49 -04:00
committed by GitHub
parent ea4c205a37
commit 3b8841ee3b
6 changed files with 38 additions and 11 deletions
+3 -4
View File
@@ -187,15 +187,14 @@ class Job(models.Model):
"""
Mark the job as completed, optionally specifying a particular termination status.
"""
valid_statuses = JobStatusChoices.TERMINAL_STATE_CHOICES
if status not in valid_statuses:
if status not in JobStatusChoices.TERMINAL_STATE_CHOICES:
raise ValueError(
_("Invalid status for job termination. Choices are: {choices}").format(
choices=', '.join(valid_statuses)
choices=', '.join(JobStatusChoices.TERMINAL_STATE_CHOICES)
)
)
# Mark the job as completed
# Set the job's status and completion time
self.status = status
if error:
self.error = error