Skip to content

Commit b31d498

Browse files
authored
RQ changed how the set jobs to failed. Dealing with this. (#2405)
1 parent afc488d commit b31d498

File tree

1 file changed

+4
-1
lines changed
  • sentry_sdk/integrations

1 file changed

+4
-1
lines changed

sentry_sdk/integrations/rq.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from rq.timeouts import JobTimeoutException
2121
from rq.version import VERSION as RQ_VERSION
2222
from rq.worker import Worker
23+
from rq.job import JobStatus
2324
except ImportError:
2425
raise DidNotEnable("RQ not installed")
2526

@@ -95,7 +96,9 @@ def sentry_patched_perform_job(self, job, *args, **kwargs):
9596

9697
def sentry_patched_handle_exception(self, job, *exc_info, **kwargs):
9798
# type: (Worker, Any, *Any, **Any) -> Any
98-
if job.is_failed:
99+
# Note, the order of the `or` here is important,
100+
# because calling `job.is_failed` will change `_status`.
101+
if job._status == JobStatus.FAILED or job.is_failed:
99102
_capture_exception(exc_info) # type: ignore
100103

101104
return old_handle_exception(self, job, *exc_info, **kwargs)

0 commit comments

Comments
 (0)