-
-
Notifications
You must be signed in to change notification settings - Fork 523
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
tox
hangs on CTRL+C, with a zombie child process
#3056
Comments
Can you open a PR there too please? Thanks! |
Will do! Currently trying to understand how to reproduce the issue there... |
I missed that the |
Issue
Pressing CTRL+C while tox is running a test command sometimes hangs. There is a zombie process running alongside the main
tox
process. This has been observed before, for example in #2712 or #2825 (comment)Environment
Output of
pip list
of the host Python, wheretox
is installedOutput of running tox
Output of
tox -rvv
Traceback(s) acquired using
py-spy dump -p $(pgrep tox)
while tox is hanging:Minimal example
tox.ini:
setup.py
Then, just run
tox
:When
sleep
is running, press CTRL+C. Sometimes this does exit, the output then contains the following:More analysis
The last thread,
tox-driver_0
, looks suspicious: it sits in a loop indefinitely._frontend.py:508
is inFrontend._send
, and the loop is the following:status
is, in this case, aToxCmdStatus
, and itsdone
property looks like this:So, we are looking at the
exit_code
attribute ofToxCmdStatus._execute_status
.Going down further,
_execute_status
is an instance ofLocalSubprocessExecuteStatus
,and its
exit_code
property implementation looks like this:... where
self._process
is aPopen
instance. Now, checking [the documentation ofPopen.returncode
, it states the following:As we don't
wait
,communicate
orpoll
in the loop above, thereturncode
is not being set, if it wasn't already set before we entered the loop (or another thread callswait
orpoll
for us...).Possible fix
If we modify
LocalSubprocessExecuteStatus.exit_code
to callPopen.poll
, the hang does not happen anymore:Note: there is similar code in pyproject-api which might also need a fix.
The text was updated successfully, but these errors were encountered: