Skip to content

Commit f98255a

Browse files
authored
fix: Ignore Celery exceptions used for control flow (getsentry#355)
* fix: Ignore Celery exceptions used for control flow * fix: Linters
1 parent a843018 commit f98255a

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

sentry_sdk/integrations/celery.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22

33
import sys
44

5-
from celery.exceptions import SoftTimeLimitExceeded, Retry # type: ignore
5+
from celery.exceptions import ( # type: ignore
6+
SoftTimeLimitExceeded,
7+
Retry,
8+
Ignore,
9+
Reject,
10+
)
611

712
from sentry_sdk.hub import Hub
813
from sentry_sdk.utils import capture_internal_exceptions, event_from_exception
@@ -12,6 +17,9 @@
1217
from sentry_sdk.integrations.logging import ignore_logger
1318

1419

20+
CELERY_CONTROL_FLOW_EXCEPTIONS = (Retry, Ignore, Reject)
21+
22+
1523
class CeleryIntegration(Integration):
1624
identifier = "celery"
1725

@@ -137,7 +145,7 @@ def _capture_exception(task, exc_info):
137145

138146
if hub.get_integration(CeleryIntegration) is None:
139147
return
140-
if isinstance(exc_info[1], Retry):
148+
if isinstance(exc_info[1], CELERY_CONTROL_FLOW_EXCEPTIONS):
141149
return
142150
if hasattr(task, "throws") and isinstance(exc_info[1], task.throws):
143151
return

0 commit comments

Comments
 (0)