-
-
Notifications
You must be signed in to change notification settings - Fork 32k
bpo-40094: Add test.support.wait_process() #19254
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
Conversation
Moreover, the following tests now check the child process exit code: * test_os.PtyTests * test_mailbox.test_lock_conflict() * test_tempfile.test_process_awareness() * test_uuid.testIssue8621() * multiprocessing resource tracker tests
I have other pending changes for test_thread, test_threading, test_fork1, test_wait3 and test_wait4 that I will submit once this PR is merged. These tests require more work and so I prefer to submit a separated PR. |
|
|
I wish to suggest a change. Sometimes I just want to wait for a PID, without checking its exit status (this is a common use case in psutil test suite). As such I would remove What do you think? Also, subprocess module on Windows uses WaitForSingleObject + GetExitCodeProcess (I do the same in psutil) while here you use os.waitpid(). I'm not sure about the differences in this specific context but... are you sure it serves the intended purpose (I don't)? |
I suggest to modify the function to return the exitcode, and accept exitcode=None parameter: in this case, ignore the exitcode. |
Sounds good to me. |
I can make a PR (or up to you, either way am fine). |
I don't need wait_process(exitcode=None), so go ahead if you want to write it :-) |
wait_process() code is a refactoring of existing code which used os.waitpid(): see commit 278c1e1. Currently, wait_process() uses os.waitpid() on Windows which means _cwait(). os.waitpid() shifts left the status by 8 bits, os.waitstatus_to_exitcode() shifts it right by 8 bits back. It would be interesting to rewrite wait_process() with WaitForSingleObject() but I was just lazy to implement it. For example, timeout is ignored (not supported) on Windows. Go ahead if you want to enhance the Windows implementation. |
Moreover, the following tests now check the child process exit code:
https://bugs.python.org/issue40094