[paramiko] SSHClient and timeouts
Robey Pointer
robey at lag.net
Sat Nov 4 14:28:24 PST 2006
On 13 Oct 2006, at 12:04, Mike McGrath wrote:
> On 10/13/06, Robey Pointer <robey at lag.net> wrote:
>>
>> On 9 Oct 2006, at 7:45, Mike McGrath wrote:
>>
>> > Is there any way to set a timeout while using SSHClient?
>>
>> If you're using invoke_shell(), the returned object is a Channel, so
>> you can call set_timeout() on it.
>>
>> If you're using exec_command(), it's less obvious: The returned file
>> objects have a "channel" attribute that you can use to access the
>> underlying channel, and set a timeout that way.
>
> so we're looking at something similar to:
>
> stdin, stdout, stderr = session.exec_command('blah")
> stdin.timeout(5)
> stdout.timeout(5)
> stderr.timeout(5)
Yes. The exact code would look like this:
stdin, stdout, stderr = session.exec_command('blah')
stdin.channel.settimeout(5)
stdout.channel.settimeout(5)
stderr.channel.settimeout(5)
robey
More information about the paramiko
mailing list