-
Notifications
You must be signed in to change notification settings - Fork 67
Windows: WindowsError in def _shutdown(self): in repository.py when running many commands #78
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
Comments
Sorry for the delayed response. Thanks for reporting this issue and suggesting a repair. It would be really helpful to know if this behavior still happens on the head of the master branch with Python 3.5+. If you'd be willing to try that out, it would be appreciated. |
Hey @jpgrayson , this issue happens to me on Windows with Python 3.9. It seems to be flaky. StackOverflow recommends using taskkill.exe as a fallback: https://stackoverflow.com/questions/6688815/windowserror-error-5-access-is-denied Doing what I proposed back in the description would at least silence the error. |
I appreciate the followup, @null77. I've gone ahead and applied the workaround you suggested. I believe what is happening is that closing stdin of the child process causes that process to terminate. On non-Windows platforms, the process remains in a defunct/zombie state until On Windows, however, the process model is different and it seems that the child process just ceases to exist such that Another approach might have been to eliminate the |
Thank you! I'll give the new version a shot. |
@jpgrayson oops, looks like somewhere in the shuffle this exception became
Originally I had posted it as a |
Thanks for the quick feedback, @null77. Could you check the behavior with the
My theory is that the explicit close of stdin is causing this race and I don't know why explicitly closing stdin would be necessary anyway. |
Addresses #78 Closing stdin of the child git process to terminate itself. On Windows, the subsequent attempt to kill the already-terminating child process results in an exception (PermissionError or WindowsError or OSError). On Linux, the terminated child process remains in a defunct/zombie state so that the subsequent kill is idempotent and the child is finalized by wait(). Signed-off-by: Peter Grayson <[email protected]>
This allows CatFileProcess and DiffTreeProcess to use Popen.terminate() instead of os.kill(). Popen.terminate() uses _winapi.TerminateProcess() and comprehends the potential PermissionError if the process is already terminated. This also allows using the Popen instance as a context manager, where its __exit__() method cleans-up descriptors and waits for the terminated child process. And since all current uses of Run.run_background() do not want to use an encoding for stdin/stdout, asserts are added to only allow this mode. Lastly, Popen.stdout.read1() is used instead of os.read(), thus elimnating all instances of os interfaces being used with these background processes. Affects #78. Signed-off-by: Peter Grayson <[email protected]>
Thanks @jpgrayson ! Sorry I didn't follow-up earlier. I removed the stdin close and the error was no longer showing up. |
Using a .23 build of stgit I could reproduce this every time just by running
stg pull
:I fixed this with the following update:
I believe what's happening here is that the PID is no longer valid and we're trying to kill an already-dead process.
The text was updated successfully, but these errors were encountered: