Bug report
Bug description
On Windows, python -m profiling.sampling run ... --blocking hangs indefinitely and writes a 0-byte profile, even for a trivial script that runs in well under a second natively. The same command without --blocking works and produces a small, loadable binary profile.
Reproducer
tiny_cpu.py:
def work(n):
total = 0
for i in range(n):
total += i * i
return total
if __name__ == "__main__":
print(work(2_000_000))
Working (no --blocking):
python -m profiling.sampling run --binary -o ok.bin --mode=cpu tiny_cpu.py
→ exits 0 in ~1s; ok.bin is ~1.4 KB (~60 samples) and replays fine.
Broken (--blocking):
python -m profiling.sampling run --binary -o blocking.bin --mode=cpu --blocking tiny_cpu.py
→ the target script's own work completes (its print output appears), but the profiler process never exits. After 25s (the script runs in <0.2s natively) it was still running and had to be killed. blocking.bin is 0 bytes, so it cannot be replayed (replay rejects it as "not a binary sampling profile").
Observed vs expected
- Observed: on Windows,
--blocking hangs (well over 100× the target's native runtime) and leaves an empty, unreplayable artifact.
- Expected:
--blocking finishes near native runtime and writes a loadable binary profile, like the non-blocking path.
CPython versions tested on
3.15.0b3 (Windows, x86_64). Please verify against current main in case this is already addressed.
Operating systems tested on
Windows
Bug report
Bug description
On Windows,
python -m profiling.sampling run ... --blockinghangs indefinitely and writes a 0-byte profile, even for a trivial script that runs in well under a second natively. The same command without--blockingworks and produces a small, loadable binary profile.Reproducer
tiny_cpu.py:Working (no
--blocking):→ exits
0in ~1s;ok.binis ~1.4 KB (~60 samples) and replays fine.Broken (
--blocking):→ the target script's own work completes (its
printoutput appears), but the profiler process never exits. After 25s (the script runs in <0.2s natively) it was still running and had to be killed.blocking.binis 0 bytes, so it cannot be replayed (replayrejects it as "not a binary sampling profile").Observed vs expected
--blockinghangs (well over 100× the target's native runtime) and leaves an empty, unreplayable artifact.--blockingfinishes near native runtime and writes a loadable binary profile, like the non-blocking path.CPython versions tested on
3.15.0b3 (Windows, x86_64). Please verify against current
mainin case this is already addressed.Operating systems tested on
Windows