-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test.support.os_helper.rmdir(): PermissionError: [WinError 32] The process cannot access the file because it is being used by another process #98219
Comments
The current wait works around an asynchronous unlink of one or more child files or directories. In this case, deleting a file or directory succeeds synchronously, but it might remain linked in the parent directory until all handles to it have been closed1. A permission error would be because a file or directory is opened without sharing delete access, or because some file or directory in the tree is open. Ideally a worker process and its child processes should already be terminated by the time we try to delete the temporary directory. However, Ideally, each worker should be created in a new process group and added to a job object. Begin by calling This functionality could be implemented in Footnotes
|
@eryksun Lines 7985 to 7992 in 05e4886
However, I don't know job objects. Why are they necessary if we already can terminate the whole process group subtree? |
I don't want to touch that mess, or perpetuate any further dependence on it. On Windows, What makes matters worse is that WinAPI
Any process in the group can choose to handle Sending the break event is an attempt to be polite for processes that support it. But after the timeout, we really need to ensure that all remaining processes in the job itself are forcefully terminated via The only processes that escape this net will be those spawned with the flags |
…nGH-99464) (cherry picked from commit 619cadc) Co-authored-by: Kumar Aditya <[email protected]>
(cherry picked from commit 619cadc) Co-authored-by: Kumar Aditya <[email protected]>
* main: (8272 commits) Update Windows readme.txt to clarify Visual Studio required versions (pythonGH-99522) pythongh-99460 Emscripten trampolines on optimized METH_O and METH_NOARGS code paths (python#99461) pythongh-92647: [Enum] use final status to determine lookup or create (pythonGH-99500) pythongh-81057: Move Globals in Core Code to _PyRuntimeState (pythongh-99496) Post 3.12.0a2 pythongh-99300: Use Py_NewRef() in Python/Python-ast.c (python#99499) pythongh-93649: Split pytime and datetime tests from _testcapimodule.c (python#99494) pythongh-99370: fix test_zippath_from_non_installed_posix (pythonGH-99483) pythonGH-99205: remove `_static` field from `PyThreadState` and `PyInterpreterState` (pythonGH-99385) pythongh-81057: Move the Remaining Import State Globals to _PyRuntimeState (pythongh-99488) pythongh-87604: Avoid publishing list of active per-interpreter audit hooks via the gc module (pythonGH-99373) pythongh-93649: Split getargs tests from _testcapimodule.c (python#99346) pythongh-81057: Move Global Variables Holding Objects to _PyRuntimeState. (pythongh-99487) pythonGH-98219: reduce sleep time in `asyncio` subprocess test (python#99464) pythonGH-99388: add `loop_factory` parameter to `asyncio.run` (python#99462) pythongh-99300: Use Py_NewRef() in PC/ directory (python#99479) pythongh-99300: Use Py_NewRef() in Doc/ directory (python#99480) pythongh-99300: Use Py_NewRef() in Modules/ directory (python#99473) pythongh-99300: Use Py_NewRef() in Modules/ directory (python#99469) pythongh-99370: Calculate zip path from prefix when in a venv (pythonGH-99371) ...
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.
For 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.
But 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.
If os.rmdir() fails with PermissionError, it would be nice to try again later.
Notes:
Linked PRs
asyncio
subprocess test #99464asyncio
subprocess test (GH-99464) #99504The text was updated successfully, but these errors were encountered: