Skip to content

Commit 899a631

Browse files
committed
bugfix: make most_recent_exception thread-local
As long as event processors aren't called in the transport, but in the the thread where the exception was captured, this should still cover the most important cases. The old version was really not working at all if you consider exceptions happening on different threads
1 parent 5e62ec7 commit 899a631

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

sentry_sdk/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,14 +354,14 @@ def __len__(self):
354354

355355
class DefaultEventProcessor(object):
356356
def __init__(self):
357-
self._most_recent_exception = None
357+
self._most_recent_exception = ContextVar("most-recent-exception")
358358

359359
def __call__(self, event):
360360
if event._exc_value is None:
361361
return
362-
if self._most_recent_exception is event._exc_value:
362+
if self._most_recent_exception.get(None) is event._exc_value:
363363
raise SkipEvent()
364-
self._most_recent_exception = event._exc_value
364+
self._most_recent_exception.set(event._exc_value)
365365

366366

367367
class SkipEvent(Exception):

0 commit comments

Comments
 (0)