paramiko 超时(python) [英] Timeout in paramiko (python)
本文介绍了paramiko 超时(python)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在寻找一种为此设置超时的方法:
I'm looking for a way to set a timeout for this:
transport = paramiko.Transport((host, port))
transport.connect(username = username, password = password)
sftp = paramiko.SFTPClient.from_transport(transport)
sftp.get(remotepath, localpath)
sftp.close()
transport.close()
推荐答案
可以使用 timeout
参数设置连接超时时间(表示连接的秒数如此处) 所述超时connect
函数.
The connection timeout can be set with the timeout
parameter (that indicated the number of seconds for the time out as described here) of the connect
function.
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(host, username=username, password=password, timeout=10)
sftp = ssh.open_sftp()
sftp.get(remotepath, localpath)
sftp.close()
这篇关于paramiko 超时(python)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文