Skip to content

Commit 04038bb

Browse files
committed
Address code review comments
1 parent 48eb039 commit 04038bb

3 files changed

Lines changed: 13 additions & 4 deletions

File tree

sentry_sdk/integrations/huey.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from sentry_sdk.tracing_utils import has_span_streaming_enabled
1717
from sentry_sdk.utils import (
1818
SENSITIVE_DATA_SUBSTITUTE,
19+
_register_control_flow_exception,
1920
capture_internal_exceptions,
2021
ensure_integration_enabled,
2122
event_from_exception,
@@ -55,6 +56,9 @@ class HueyIntegration(Integration):
5556
def setup_once() -> None:
5657
patch_enqueue()
5758
patch_execute()
59+
_register_control_flow_exception(
60+
[CancelExecution, RetryTask, TaskLockedException]
61+
)
5862

5963

6064
def patch_enqueue() -> None:

sentry_sdk/utils.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090

9191
# These exceptions won't set the span status to error if they occur. Use
9292
# register_control_flow_exception to add to this list
93-
_control_flow_exception_classes: "list[type]" = []
93+
_control_flow_exception_classes: "set[type]" = set()
9494

9595

9696
def is_internal_task() -> bool:
@@ -1982,8 +1982,13 @@ def get_current_thread_meta(
19821982
return None, None
19831983

19841984

1985-
def _register_control_flow_exception(exc_type: type) -> None:
1986-
_control_flow_exception_classes.append(exc_type)
1985+
def _register_control_flow_exception(
1986+
exc_type: "Union[type, list[type], tuple[type], set[type]]",
1987+
) -> None:
1988+
if isinstance(exc_type, (list, tuple, set)):
1989+
_control_flow_exception_classes.update(exc_type)
1990+
else:
1991+
_control_flow_exception_classes.add(exc_type)
19871992

19881993

19891994
def should_be_treated_as_error(ty: "Any", value: "Any") -> bool:

tests/integrations/huey/test_huey.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ def maybe_locked_task():
283283
assert (
284284
event["contexts"]["trace"]["status"] == "aborted"
285285
if should_be_locked
286-
else "ok"
286+
else event["contexts"]["trace"]["status"] == "ok"
287287
)
288288
assert len(huey) == 0
289289

0 commit comments

Comments
 (0)