Skip to content

SSHClient.open_sftp: Add timeout arg; pass to open_channel - #1202

Open
evanj wants to merge 3 commits into
paramiko:mainfrom
evanj:sftp-open-timeout
Open

evanj wants to merge 3 commits into
paramiko:mainfrom
evanj:sftp-open-timeout

Conversation

@evanj

@evanj evanj commented May 1, 2018

Copy link
Copy Markdown

The default channel timeout is 1 hour. When connecting to slow SFTP
servers, they can take a long time to respond, which results in a
hung connection. Add an optional timeout argument to
SSHClient.open_sftp which gets passed into Transport.open_channel
so callers can get an early SSHException.

The default channel timeout is 1 hour. When connecting to slow SFTP
servers, they can take a long time to respond, which results in a
hung connection. Add an optional timeout argument to
SSHClient.open_sftp which gets passed into Transport.open_channel
so callers can get an early SSHException.
@evanj
evanj force-pushed the sftp-open-timeout branch from 9153df0 to c7c376e Compare May 1, 2018 17:48
@bitprophet bitprophet added this to the 2.5.0 milestone May 1, 2018
Comment thread tests/test_sftp.py Outdated
verify that the open_sftp has a configurable timeout
"""

# copied from conftest.sftp_server

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was there a reason this was copied instead of just used directly?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That function connects the client socket directly to a Transport and returns it. I needed just the socket, so I can pass it into SSHClient to test SSHClient.open_sftp and all the other functions it calls.

Now that I think about it: I could split that function into two, a lower level one that returns the client socket, which is used by conftest.sftp_server and by this test. Would that make sense?

@evanj

evanj commented May 1, 2018

Copy link
Copy Markdown
Author

I've attempted to refactor the test to eliminate the test duplication. Hopefully this makes more sense, thanks for the helpful feedback!

@ManniCS

ManniCS commented Jun 28, 2018

Copy link
Copy Markdown

@bitprophet any thoughts on how this Pull Request could be improved in order for it to be merged to master?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants