码迷,mamicode.com
首页 > 其他好文 > 详细

paramiko 遭遇socket.error: Socket is closed 错误的解决办法

时间:2016-09-01 02:01:24      阅读:1462      评论:0      收藏:0      [点我收藏+]

标签:

似乎是connection自己断了解决的办法是在创建conn的时候添加下面这句

conn.keep_this = conn_session

完整代码




def create_a_conn(ip_addr, port, username, password):
‘‘‘
creat a conn to router using paramiko.SSHClient()
‘‘‘
conn_session = paramiko.SSHClient()
conn_session.load_system_host_keys()
conn_session.connect(ip_addr, port, username, password, look_for_keys = False, allow_agent = False)
conn = conn_session.invoke_shell()# to keep the session go on
conn.keep_this = conn_session

time.sleep(1)
conn.send("terminal length 0\n")
time.sleep(1)

if conn.recv_ready():
conn.recv(65535)

return conn
?

paramiko 遭遇socket.error: Socket is closed 错误的解决办法

标签:

原文地址:http://www.cnblogs.com/Vooom/p/5820644.html

(1)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!