Skip to content

Commit 9c35e83

Browse files
committed
test that shows we are leaking scope changes
1 parent 7d14008 commit 9c35e83

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/integrations/threading/test_threading.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,3 +226,26 @@ def do_some_work(number):
226226
assert (
227227
wrong_span_found_in_trx
228228
), "No wrong span found in transaction. It is excepted that there is one. (as we are testing a race condition, this test might fail randomly)"
229+
230+
231+
def test_scope_data_not_leaked_in_threads(sentry_init):
232+
sentry_init(
233+
traces_sample_rate=1.0,
234+
integrations=[ThreadingIntegration(propagate_hub=True)],
235+
)
236+
237+
initial_iso_scope = sentry_sdk.get_isolation_scope()
238+
239+
def do_some_work(number):
240+
# change data in isolation scope in thread
241+
sentry_sdk.set_tag("foo", "bar")
242+
243+
with futures.ThreadPoolExecutor(max_workers=2) as executor:
244+
all_futures = []
245+
for number in range(10):
246+
all_futures.append(executor.submit(do_some_work, number))
247+
futures.wait(all_futures)
248+
249+
assert (
250+
initial_iso_scope._tags == {}
251+
), "The isolation scope in the main thread should not be modified by the started threads."

0 commit comments

Comments
 (0)