From 7d031a137ca71af09bc582387dd4b5da6e2c6b10 Mon Sep 17 00:00:00 2001 From: Thomas Kowalski Date: Tue, 3 Mar 2026 10:57:24 +0100 Subject: [PATCH 1/4] gh-145458: use self.skip_idle --- Lib/profiling/sampling/stack_collector.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Lib/profiling/sampling/stack_collector.py b/Lib/profiling/sampling/stack_collector.py index 4e213cfe41ca24..3bb519c362d20e 100644 --- a/Lib/profiling/sampling/stack_collector.py +++ b/Lib/profiling/sampling/stack_collector.py @@ -19,9 +19,9 @@ def __init__(self, sample_interval_usec, *, skip_idle=False): self.sample_interval_usec = sample_interval_usec self.skip_idle = skip_idle - def collect(self, stack_frames, timestamps_us=None, skip_idle=False): + def collect(self, stack_frames, timestamps_us=None): weight = len(timestamps_us) if timestamps_us else 1 - for frames, thread_id in self._iter_stacks(stack_frames, skip_idle=skip_idle): + for frames, thread_id in self._iter_stacks(stack_frames, skip_idle=self.skip_idle): self.process_frames(frames, thread_id, weight=weight) def process_frames(self, frames, thread_id, weight=1): @@ -88,7 +88,7 @@ def __init__(self, *args, **kwargs): # Per-thread statistics self.per_thread_stats = {} # {thread_id: {has_gil, on_cpu, gil_requested, unknown, has_exception, total, gc_samples}} - def collect(self, stack_frames, timestamps_us=None, skip_idle=False): + def collect(self, stack_frames, timestamps_us=None): """Override to track thread status statistics before processing frames.""" # Weight is number of timestamps (samples with identical stack) weight = len(timestamps_us) if timestamps_us else 1 @@ -123,7 +123,7 @@ def collect(self, stack_frames, timestamps_us=None, skip_idle=False): self.per_thread_stats[thread_id][key] += value * weight # Call parent collect to process frames - super().collect(stack_frames, timestamps_us, skip_idle=skip_idle) + super().collect(stack_frames, timestamps_us) def set_stats(self, sample_interval_usec, duration_sec, sample_rate, error_rate=None, missed_samples=None, mode=None): From e80c1a1460ba0f455d57ac71bd3cf1df92800394 Mon Sep 17 00:00:00 2001 From: Thomas Kowalski Date: Mon, 9 Mar 2026 09:21:24 +0100 Subject: [PATCH 2/4] news: add news entry --- .../next/Library/2026-03-09-09-21-02.gh-issue-145458.mqQUFZ.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2026-03-09-09-21-02.gh-issue-145458.mqQUFZ.rst diff --git a/Misc/NEWS.d/next/Library/2026-03-09-09-21-02.gh-issue-145458.mqQUFZ.rst b/Misc/NEWS.d/next/Library/2026-03-09-09-21-02.gh-issue-145458.mqQUFZ.rst new file mode 100644 index 00000000000000..f424cb7120dd27 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-03-09-09-21-02.gh-issue-145458.mqQUFZ.rst @@ -0,0 +1,2 @@ +Use the instance ``skip_idle`` attribute instead of passing it as a parameter +in :class:`profiling.sampling.stack_collector.StackCollector`. From d8144773343c51bc2976826ad8bafd6aaa70e123 Mon Sep 17 00:00:00 2001 From: Thomas Kowalski Date: Mon, 9 Mar 2026 09:30:14 +0100 Subject: [PATCH 3/4] news: update reference to StackCollector class --- .../next/Library/2026-03-09-09-21-02.gh-issue-145458.mqQUFZ.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2026-03-09-09-21-02.gh-issue-145458.mqQUFZ.rst b/Misc/NEWS.d/next/Library/2026-03-09-09-21-02.gh-issue-145458.mqQUFZ.rst index f424cb7120dd27..f1a1bd1048933f 100644 --- a/Misc/NEWS.d/next/Library/2026-03-09-09-21-02.gh-issue-145458.mqQUFZ.rst +++ b/Misc/NEWS.d/next/Library/2026-03-09-09-21-02.gh-issue-145458.mqQUFZ.rst @@ -1,2 +1,2 @@ Use the instance ``skip_idle`` attribute instead of passing it as a parameter -in :class:`profiling.sampling.stack_collector.StackCollector`. +in ``StackCollector``. From 4a771f158e8d6695950053e73c2f7fd82bd0b75e Mon Sep 17 00:00:00 2001 From: Thomas Kowalski Date: Fri, 13 Mar 2026 14:03:28 +0100 Subject: [PATCH 4/4] news: remove news entry --- .../next/Library/2026-03-09-09-21-02.gh-issue-145458.mqQUFZ.rst | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 Misc/NEWS.d/next/Library/2026-03-09-09-21-02.gh-issue-145458.mqQUFZ.rst diff --git a/Misc/NEWS.d/next/Library/2026-03-09-09-21-02.gh-issue-145458.mqQUFZ.rst b/Misc/NEWS.d/next/Library/2026-03-09-09-21-02.gh-issue-145458.mqQUFZ.rst deleted file mode 100644 index f1a1bd1048933f..00000000000000 --- a/Misc/NEWS.d/next/Library/2026-03-09-09-21-02.gh-issue-145458.mqQUFZ.rst +++ /dev/null @@ -1,2 +0,0 @@ -Use the instance ``skip_idle`` attribute instead of passing it as a parameter -in ``StackCollector``.