Skip to content

Commit 6894efc

Browse files
use correct scopes
1 parent 7423d8a commit 6894efc

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

sentry_sdk/integrations/threading.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,16 +150,19 @@ def sentry_submit(self, fn, *args, **kwargs):
150150
if integration is None:
151151
return func(self, fn, *args, **kwargs)
152152

153-
def wrapped_fn(*args, **kwargs):
154-
# type: (*Any, **Any) -> Any
155-
if not integration.propagate_scope:
156-
return fn(*args, **kwargs)
157-
153+
if integration.propagate_scope:
158154
isolation_scope = sentry_sdk.get_isolation_scope().fork()
159155
current_scope = sentry_sdk.get_current_scope().fork()
160-
with use_isolation_scope(isolation_scope):
161-
with use_scope(current_scope):
162-
return fn(*args, **kwargs)
156+
else:
157+
isolation_scope = None
158+
current_scope = None
159+
160+
def wrapped_fn(*args, **kwargs):
161+
# type: (*Any, **Any) -> Any
162+
if isolation_scope is not None and current_scope is not None:
163+
with use_isolation_scope(isolation_scope):
164+
with use_scope(current_scope):
165+
return fn(*args, **kwargs)
163166

164167
return func(self, wrapped_fn, *args, **kwargs)
165168

0 commit comments

Comments
 (0)