Title: test.support.os_helper.rmdir(): PermissionError: [WinError 32] The process cannot access the file because it is being used by another process · Issue #98219 · python/cpython · GitHub
Open Graph Title: test.support.os_helper.rmdir(): PermissionError: [WinError 32] The process cannot access the file because it is being used by another process · Issue #98219 · python/cpython
X Title: test.support.os_helper.rmdir(): PermissionError: [WinError 32] The process cannot access the file because it is being used by another process · Issue #98219 · python/cpython
Description: On Windows, it's common that a test fails at exit when trying to remove a temporary directory created by a test. Usually, it's because the test spawns a child process in this directory and the test tries to remove the temporary directory...
Open Graph Description: On Windows, it's common that a test fails at exit when trying to remove a temporary directory created by a test. Usually, it's because the test spawns a child process in this directory and the test...
X Description: On Windows, it's common that a test fails at exit when trying to remove a temporary directory created by a test. Usually, it's because the test spawns a child process in this directory and ...
Opengraph URL: https://github.com/python/cpython/issues/98219
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"test.support.os_helper.rmdir(): PermissionError: [WinError 32] The process cannot access the file because it is being used by another process","articleBody":"On Windows, it's common that a test fails at exit when trying to remove a temporary directory created by a test. Usually, it's because the test spawns a child process in this directory and the test tries to remove the temporary directory before the child process completes.\r\n\r\nFor example, temp_dir() of test.support.os_helper creates a temporary directory and then deletes it with rmtree(path) of test.support.os_helper: this function is different than shutil.rmtree(), it tries again on error with a timeout of 1.0 second.\r\n\r\nBut sometimes, the function fails with the error \"PermissionError: [WinError 32] The process cannot access the file because it is being used by another process\" on the os.rmdir() step.\r\n\r\nIf os.rmdir() fails with PermissionError, it would be nice to try again later.\r\n\r\nNotes:\r\n\r\n* I'm not sure why there is a fixed timeout of 1.0 second. I would prefer to use SHORT_TIMEOUT, or even LONG_TIMEOUT, of test.support.\r\n* _force_run() should use test.support.sleeping_retry()\r\n\r\n```\r\nTraceback (most recent call last):\r\n File \"D:\\a\\cpython\\cpython\\Lib\\test\\support\\os_helper.py\", line 483, in temp_dir\r\n yield path\r\n File \"D:\\a\\cpython\\cpython\\Lib\\test\\support\\os_helper.py\", line 536, in temp_cwd\r\n yield cwd_dir\r\n File \"D:\\a\\cpython\\cpython\\Lib\\test\\libregrtest\\main.py\", line 701, in main\r\n self._main(tests, kwargs)\r\n File \"D:\\a\\cpython\\cpython\\Lib\\test\\libregrtest\\main.py\", line 722, in _main\r\n run_tests_worker(self.ns, self.worker_test_name)\r\n File \"D:\\a\\cpython\\cpython\\Lib\\test\\libregrtest\\runtest_mp.py\", line 101, in run_tests_worker\r\n sys.exit(0)\r\nSystemExit: 0\r\n\r\nDuring handling of the above exception, another exception occurred:\r\n\r\nTraceback (most recent call last):\r\n File \"D:\\a\\cpython\\cpython\\Lib\\test\\support\\__init__.py\", line 203, in _force_run\r\n return func(*args)\r\n ^^^^^^^^^^^\r\nPermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'D:\\\\a\\\\cpython\\\\cpython\\\\build\\\\test_python_4372�\\\\test_python_worker_1096�'\r\n\r\nDuring handling of the above exception, another exception occurred:\r\n\r\nTraceback (most recent call last):\r\n File \"D:\\a\\cpython\\cpython\\Lib\\runpy.py\", line 198, in _run_module_as_main\r\n return _run_code(code, main_globals, None,\r\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n File \"D:\\a\\cpython\\cpython\\Lib\\runpy.py\", line 88, in _run_code\r\n exec(code, run_globals)\r\n File \"D:\\a\\cpython\\cpython\\Lib\\test\\regrtest.py\", line 47, in \u003cmodule\u003e\r\n _main()\r\n File \"D:\\a\\cpython\\cpython\\Lib\\test\\regrtest.py\", line 43, in _main\r\n main()\r\n File \"D:\\a\\cpython\\cpython\\Lib\\test\\libregrtest\\main.py\", line 763, in main\r\n Regrtest().main(tests=tests, **kwargs)\r\n File \"D:\\a\\cpython\\cpython\\Lib\\test\\libregrtest\\main.py\", line 695, in main\r\n with os_helper.temp_cwd(test_cwd, quiet=True):\r\n File \"D:\\a\\cpython\\cpython\\Lib\\contextlib.py\", line 155, in __exit__\r\n self.gen.throw(value)\r\n File \"D:\\a\\cpython\\cpython\\Lib\\test\\support\\os_helper.py\", line 534, in temp_cwd\r\n with temp_dir(path=name, quiet=quiet) as temp_path:\r\n File \"D:\\a\\cpython\\cpython\\Lib\\contextlib.py\", line 155, in __exit__\r\n self.gen.throw(value)\r\n File \"D:\\a\\cpython\\cpython\\Lib\\test\\support\\os_helper.py\", line 488, in temp_dir\r\n rmtree(path)\r\n File \"D:\\a\\cpython\\cpython\\Lib\\test\\support\\os_helper.py\", line 445, in rmtree\r\n _rmtree(path)\r\n File \"D:\\a\\cpython\\cpython\\Lib\\test\\support\\os_helper.py\", line 389, in _rmtree\r\n _waitfor(lambda p: _force_run(p, os.rmdir, p), path)\r\n File \"D:\\a\\cpython\\cpython\\Lib\\test\\support\\os_helper.py\", line 333, in _waitfor\r\n func(pathname)\r\n File \"D:\\a\\cpython\\cpython\\Lib\\test\\support\\os_helper.py\", line 389, in \u003clambda\u003e\r\n _waitfor(lambda p: _force_run(p, os.rmdir, p), path)\r\n ^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n File \"D:\\a\\cpython\\cpython\\Lib\\test\\support\\__init__.py\", line 214, in _force_run\r\n return func(*args)\r\n ^^^^^^^^^^^\r\nPermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'D:\\\\a\\\\cpython\\\\cpython\\\\build\\\\test_python_4372�\r\n```\r\n\r\n\u003c!-- gh-linked-prs --\u003e\r\n### Linked PRs\r\n- gh-99464\r\n- gh-99504\r\n\r\n\u003c!-- /gh-linked-prs --\u003e\r\n","author":{"url":"https://github.com/vstinner","@type":"Person","name":"vstinner"},"datePublished":"2022-10-12T15:17:28.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/98219/cpython/issues/98219"}
| 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:0e73a5d3-3ffa-86d6-2343-2ef80c0da16a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C778:C5A79:59A97B:7CE0BC:69694CAD |
| html-safe-nonce | f35a680988dfd921276efc20753574e15118a7f9474100d13059e3618e50ffa9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNzc4OkM1QTc5OjU5QTk3Qjo3Q0UwQkM6Njk2OTRDQUQiLCJ2aXNpdG9yX2lkIjoiODgyMzI0NjI0MTAxMzUxNzQ4NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | f3050cbbd2ca19b579410f1c64d01110307298511c1ad2f2395999a6d02b3297 |
| hovercard-subject-tag | issue:1406393022 |
| 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/98219/issue_layout |
| twitter:image | https://opengraph.githubassets.com/6585a8d2a6dc0f095fae2cc1b46b942750d1da7b6d6e8fa3a029edf2a7395bc0/python/cpython/issues/98219 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/6585a8d2a6dc0f095fae2cc1b46b942750d1da7b6d6e8fa3a029edf2a7395bc0/python/cpython/issues/98219 |
| og:image:alt | On Windows, it's common that a test fails at exit when trying to remove a temporary directory created by a test. Usually, it's because the test spawns a child process in this directory and the test... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | vstinner |
| hostname | github.com |
| expected-hostname | github.com |
| None | 54182691a21263b584d2e600b758e081b0ff1d10ffc0d2eefa51cf754b43b51d |
| 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 | d69ac0477df0f87da03b8b06cebd187012d7a930 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width