Skip to content

Commit 0a80b0e

Browse files
committed
fix(integrations): Check retries_left before capturing exception
Bring back compatibility across rq versions Fixes GH-3707
1 parent 1bd744d commit 0a80b0e

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

sentry_sdk/integrations/rq.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ def sentry_patched_perform_job(self, job, *args, **kwargs):
9090

9191
def sentry_patched_handle_exception(self, job, *exc_info, **kwargs):
9292
# type: (Worker, Any, *Any, **Any) -> Any
93-
# Note, the order of the `or` here is important,
94-
# because calling `job.is_failed` will change `_status`.
95-
if job._status == JobStatus.FAILED or job.is_failed:
93+
retry = job.retries_left and job.retries_left > 0
94+
failed = job._status == JobStatus.FAILED or job.is_failed
95+
if failed and not retry:
9696
_capture_exception(exc_info)
9797

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

tests/integrations/rq/test_rq.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,6 @@ def test_traces_sampler_gets_correct_values_in_sampling_context(
254254
@pytest.mark.skipif(
255255
parse_version(rq.__version__) < (1, 5), reason="At least rq-1.5 required"
256256
)
257-
@pytest.mark.skipif(
258-
parse_version(rq.__version__) >= (2,),
259-
reason="Test broke in RQ 2.0. Investigate and fix. "
260-
"See https://github.com/getsentry/sentry-python/issues/3707.",
261-
)
262257
def test_job_with_retries(sentry_init, capture_events):
263258
sentry_init(integrations=[RqIntegration()])
264259
events = capture_events()

0 commit comments

Comments
 (0)