Terminate ruff when it times out - #77
Open
Danipulok wants to merge 1 commit into
Open
Conversation
Contributor
Author
|
Hey @samuelcolvin! I'm really sorry for pinging you if it's inappropriate Would you or someone else be able to check them? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #72.
What
ruff_checkcallsPopen.communicate(..., timeout=10)with notryaround it.The stdlib does not kill the child when that timeout fires, so a
ruffprocessthat hangs is left running and its
stdoutandstderrpipes are never closed.The call now kills the process and waits for it before letting the
TimeoutExpiredpropagate, so the error a caller sees is unchanged.Measured on a child that sleeps for 30 seconds against a 0.5 second timeout:
poll()stdinstdoutstderrTimeoutExpiredNonekill()and a secondcommunicate()-9That second row is why there is no
with Popen(...)block: the secondcommunicate()already closes every pipe, so wrapping the call would reindentthe whole function and change nothing else.
How to test
make test.test_ruff_timeout_kills_the_processreplacesPopeninpytest_examples.lintwith a subclass whose first
communicateraisesTimeoutExpiredand whosesecond delegates to the parent, so the child is a real
ruffprocess and thekill is real. Without the fix it fails on
assert ruff_process.poll() is not None.