]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-144342: Use `time.sleep` in `profiling.sampling` (#144343)
authorMaurycy Pawłowski-Wieroński <maurycy@maurycy.com>
Fri, 30 Jan 2026 15:13:21 +0000 (16:13 +0100)
committerGitHub <noreply@github.com>
Fri, 30 Jan 2026 15:13:21 +0000 (15:13 +0000)
Lib/profiling/sampling/sample.py

index f657849e72bb628a4d28a09489259b203dcd4c9b..c6abfb1c8ee8858f6e31023d2392b945f6dc70fa 100644 (file)
@@ -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":