Skip to content

Commit cf7f843

Browse files
check if flag exists
1 parent 7c33ac3 commit cf7f843

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

tests/integrations/threading/test_threading.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ def stage2():
7070
assert not exception["mechanism"]["handled"]
7171

7272
# Free-threaded builds set thread_inherit_context to True, otherwise thread_inherit_context is False
73-
# https://docs.python.org/3/howto/free-threading-python.html
74-
if propagate_hub or sys.flags.thread_inherit_context:
73+
if propagate_hub or getattr(sys.flags, "thread_inherit_context", None):
7574
assert event["tags"]["stage1"] == "true"
7675
else:
7776
assert "stage1" not in event.get("tags", {})
@@ -98,8 +97,7 @@ def double(number):
9897
sentry_sdk.flush()
9998

10099
# Free-threaded builds set thread_inherit_context to True, otherwise thread_inherit_context is False
101-
# https://docs.python.org/3/howto/free-threading-python.html
102-
if propagate_hub or sys.flags.thread_inherit_context:
100+
if propagate_hub or getattr(sys.flags, "thread_inherit_context", None):
103101
assert len(events) == 1
104102
(event,) = events
105103
assert event["spans"][0]["trace_id"] == event["spans"][1]["trace_id"]
@@ -255,8 +253,7 @@ def do_some_work(number):
255253
(event,) = events
256254

257255
# Free-threaded builds set thread_inherit_context to True, otherwise thread_inherit_context is False
258-
# https://docs.python.org/3/howto/free-threading-python.html
259-
if propagate_scope or sys.flags.thread_inherit_context:
256+
if propagate_scope or getattr(sys.flags, "thread_inherit_context", None):
260257
assert render_span_tree(event) == dedent(
261258
"""\
262259
- op="outer-trx": description=null
@@ -318,8 +315,7 @@ def do_some_work(number):
318315
(event,) = events
319316

320317
# Free-threaded builds set thread_inherit_context to True, otherwise thread_inherit_context is False
321-
# https://docs.python.org/3/howto/free-threading-python.html
322-
if propagate_scope or sys.flags.thread_inherit_context:
318+
if propagate_scope or getattr(sys.flags, "thread_inherit_context", None):
323319
assert render_span_tree(event) == dedent(
324320
"""\
325321
- op="outer-trx": description=null

0 commit comments

Comments
 (0)