Title: profiling.sampling run --blocking hangs and writes an empty profile on Windows · Issue #152356 · python/cpython · GitHub
Open Graph Title: profiling.sampling run --blocking hangs and writes an empty profile on Windows · Issue #152356 · python/cpython
X Title: profiling.sampling run --blocking hangs and writes an empty profile on Windows · Issue #152356 · python/cpython
Description: 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 --blocki...
Open Graph Description: 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 nat...
X Description: 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 nat...
Opengraph URL: https://github.com/python/cpython/issues/152356
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"profiling.sampling run --blocking hangs and writes an empty profile on Windows","articleBody":"# Bug report\r\n\r\n### Bug description\r\n\r\nOn 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.\r\n\r\n#### Reproducer\r\n\r\n`tiny_cpu.py`:\r\n\r\n```python\r\ndef work(n):\r\n total = 0\r\n for i in range(n):\r\n total += i * i\r\n return total\r\n\r\nif __name__ == \"__main__\":\r\n print(work(2_000_000))\r\n```\r\n\r\nWorking (no `--blocking`):\r\n\r\n```\r\npython -m profiling.sampling run --binary -o ok.bin --mode=cpu tiny_cpu.py\r\n```\r\n\r\n→ exits `0` in ~1s; `ok.bin` is ~1.4 KB (~60 samples) and replays fine.\r\n\r\nBroken (`--blocking`):\r\n\r\n```\r\npython -m profiling.sampling run --binary -o blocking.bin --mode=cpu --blocking tiny_cpu.py\r\n```\r\n\r\n→ the target script's own work completes (its `print` output appears), but the profiler process never exits. After 25s (the script runs in \u003c0.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\").\r\n\r\n### Observed vs expected\r\n\r\n- Observed: on Windows, `--blocking` hangs (well over 100× the target's native runtime) and leaves an empty, unreplayable artifact.\r\n- Expected: `--blocking` finishes near native runtime and writes a loadable binary profile, like the non-blocking path.\r\n\r\n### CPython versions tested on\r\n\r\n3.15.0b3 (Windows, x86_64). Please verify against current `main` in case this is already addressed.\r\n\r\n### Operating systems tested on\r\n\r\nWindows\r\n\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-152471\n* gh-152512\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/heejaechang","@type":"Person","name":"heejaechang"},"datePublished":"2026-06-27T01:04:05Z","url":"https://github.com/python/cpython/issues/152356"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a79ed6d0-b85e-2bca-e67b-c93e2f5239e9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B786:1FAE:16343C7:1D88135:6B023693 |
| html-safe-nonce | bb66f6b770e0cb6ee42fa5d1a305b02458483e02a2fc310699ca8c660812350d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNzg2OjFGQUU6MTYzNDNDNzoxRDg4MTM1OjZCMDIzNjkzIiwidmlzaXRvcl9pZCI6IjgxMDc5MTY5NDY4MTA0ODQzNzEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 537befff3da8784d183336a07d795835b4218eebac46800205c199a18994b2b4 |
| hovercard-subject-tag | issue:4756058471 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/152356/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5a058762d96ab7e320f4377b98919592dfd711cd0807927bacea2c4fa3e07373/python/cpython/issues/152356 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5a058762d96ab7e320f4377b98919592dfd711cd0807927bacea2c4fa3e07373/python/cpython/issues/152356 |
| og:image:alt | 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 nat... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | heejaechang |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width