From 61176316750c778ad0c4d9b42fb3c7963d8bc9d4 Mon Sep 17 00:00:00 2001 From: Alexander Alderman Webb Date: Wed, 22 Apr 2026 13:36:11 +0200 Subject: [PATCH 1/3] test: Join thread in continuous profiler test --- tests/profiler/test_continuous_profiler.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/profiler/test_continuous_profiler.py b/tests/profiler/test_continuous_profiler.py index f0c3b5a27f..a6a3c678a9 100644 --- a/tests/profiler/test_continuous_profiler.py +++ b/tests/profiler/test_continuous_profiler.py @@ -213,7 +213,6 @@ def assert_single_transaction_without_profile_chunks(envelopes): assert "profile" not in transaction["contexts"] -@pytest.mark.forked @pytest.mark.parametrize( "mode", [ @@ -243,7 +242,10 @@ def assert_single_transaction_without_profile_chunks(envelopes): pytest.param(get_client_options(False), id="experiment"), ], ) -@mock.patch("sentry_sdk.profiler.continuous_profiler.PROFILE_BUFFER_SECONDS", 0.01) +@mock.patch( + "sentry_sdk.profiler.continuous_profiler.ProfileBuffer.should_flush", + lambda a, b: True, +) # Force flushing profile of first transaction. def test_continuous_profiler_auto_start_and_manual_stop( sentry_init, capture_envelopes, @@ -265,7 +267,11 @@ def test_continuous_profiler_auto_start_and_manual_stop( with sentry_sdk.start_transaction(name="profiling"): with sentry_sdk.start_span(op="op"): - time.sleep(0.05) + pass + + # Wait so profiles are captured before assertions. + sentry_sdk.profiler.continuous_profiler._scheduler.running = False + sentry_sdk.profiler.continuous_profiler._scheduler.thread.join() assert_single_transaction_with_profile_chunks(envelopes, thread) From 61d98e4516b9a215bea5dcea9cf1094c56f43ba0 Mon Sep 17 00:00:00 2001 From: Alexander Alderman Webb Date: Wed, 22 Apr 2026 13:39:02 +0200 Subject: [PATCH 2/3] add forked again --- tests/profiler/test_continuous_profiler.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/profiler/test_continuous_profiler.py b/tests/profiler/test_continuous_profiler.py index a6a3c678a9..df61ca096d 100644 --- a/tests/profiler/test_continuous_profiler.py +++ b/tests/profiler/test_continuous_profiler.py @@ -213,6 +213,7 @@ def assert_single_transaction_without_profile_chunks(envelopes): assert "profile" not in transaction["contexts"] +@pytest.mark.forked @pytest.mark.parametrize( "mode", [ From 319d7f75fd27469dc4efb41e137c327ad2f5d55c Mon Sep 17 00:00:00 2001 From: Alexander Alderman Webb Date: Wed, 22 Apr 2026 15:37:52 +0200 Subject: [PATCH 3/3] use teardown method --- tests/profiler/test_continuous_profiler.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/profiler/test_continuous_profiler.py b/tests/profiler/test_continuous_profiler.py index df61ca096d..7868d4bddb 100644 --- a/tests/profiler/test_continuous_profiler.py +++ b/tests/profiler/test_continuous_profiler.py @@ -271,8 +271,7 @@ def test_continuous_profiler_auto_start_and_manual_stop( pass # Wait so profiles are captured before assertions. - sentry_sdk.profiler.continuous_profiler._scheduler.running = False - sentry_sdk.profiler.continuous_profiler._scheduler.thread.join() + sentry_sdk.profiler.continuous_profiler._scheduler.teardown() assert_single_transaction_with_profile_chunks(envelopes, thread)