Prevent Paramiko deadlock when test sends more than 2MB to stdout#779
Uh oh!
There was an error while loading. Please reload this page.
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.
The paramiko library has a known problem where checking the exit status can cause a deadlock if the command has written a lot of output to the stdout (or stderr) channel. We hit this problem when using
testinfrato return data from log files during a test.https://docs.paramiko.org/en/stable/api/channel.html#paramiko.channel.Channel.recv_exit_status
We can work around this, for the stdout case, by reading the data before checking the exit status.
I do not attempt to fix the stderr case. Fixing this would likely require a more complex fix, which reads from both stdout and stderr until they are closed, like https://stackoverflow.com/a/78765054
Here is an example of running the test case on the original code. I enabled
pytest-timeoutswith a 10 second timeout so you can see it stuck inrecv_exit_statusWith the fix, the test passes
I didn't see any regressions in the rest of the test suite.