Fixes: #17950 - Handle InvalidJobOperation error in job enqueueing test (#18062)

* Wait until job1 exists in Redis before enqueueing job2

* Job can exist but not have status

* Catch InvalidJobOperation and use as trigger for retry

* Catch InvalidJobOperation when deleting/canceling job

* Remove testing code
This commit is contained in:
bctiemann 2024-11-21 11:51:30 -05:00 committed by GitHub
parent b40ffcccb9
commit 4f7bfc836c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -9,6 +9,7 @@ from django.db import models
from django.urls import reverse
from django.utils import timezone
from django.utils.translation import gettext as _
from rq.exceptions import InvalidJobOperation
from core.choices import JobStatusChoices
from core.models import ObjectType
@ -158,7 +159,11 @@ class Job(models.Model):
job = queue.fetch_job(str(self.job_id))
if job:
job.cancel()
try:
job.cancel()
except InvalidJobOperation:
# Job may raise this exception from get_status() if missing from Redis
pass
def start(self):
"""