From be4ee8ee420adb211b77645f30ca1eb9356ed1c0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Maurycy=20Paw=C5=82owski-Wiero=C5=84ski?= Date: Fri, 30 Jan 2026 16:13:21 +0100 Subject: [PATCH] gh-144342: Use `time.sleep` in `profiling.sampling` (#144343) --- Lib/profiling/sampling/sample.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Lib/profiling/sampling/sample.py b/Lib/profiling/sampling/sample.py index f657849e72bb..c6abfb1c8ee8 100644 --- a/Lib/profiling/sampling/sample.py +++ b/Lib/profiling/sampling/sample.py @@ -100,7 +100,11 @@ class SampleProfiler: break current_time = time.perf_counter() - if next_time < current_time: + if next_time > current_time: + sleep_time = (next_time - current_time) * 0.9 + if sleep_time > 0.0001: + time.sleep(sleep_time) + elif next_time < current_time: try: with _pause_threads(self.unwinder, self.blocking): if async_aware == "all": -- 2.47.3