Skip to content

Commit 6d6e8a2

Browse files
authored
Don't fail if there is no _context_manager_state (#4698)
This is not a fix -- it just makes the SDK not propagate an internal SDK exception upwards.
1 parent 5f2adcf commit 6d6e8a2

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

sentry_sdk/profiler/transaction_profiler.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
)
4646
from sentry_sdk.utils import (
4747
capture_internal_exception,
48+
capture_internal_exceptions,
4849
get_current_thread_meta,
4950
is_gevent,
5051
is_valid_sample_rate,
@@ -369,12 +370,13 @@ def __enter__(self):
369370

370371
def __exit__(self, ty, value, tb):
371372
# type: (Optional[Any], Optional[Any], Optional[Any]) -> None
372-
self.stop()
373+
with capture_internal_exceptions():
374+
self.stop()
373375

374-
scope, old_profile = self._context_manager_state
375-
del self._context_manager_state
376+
scope, old_profile = self._context_manager_state
377+
del self._context_manager_state
376378

377-
scope.profile = old_profile
379+
scope.profile = old_profile
378380

379381
def write(self, ts, sample):
380382
# type: (int, ExtractedSample) -> None

0 commit comments

Comments
 (0)