Ho scritto un semplice programma per creare una connessione SSH tramite paramiko e quindi eseguire un semplice comando. Ma getta sempre un errore di eccezione: -Errore di eccezione ottenuto "Eccezione nella discussione Thread-1 (molto probabilmente generata durante l'arresto dell'interprete)" che utilizza Paramiko
Exception in thread Thread-1 (most likely raised during interpreter shutdown): Traceback (most recent call last): File "/usr/lib/python2.7/threading.py", line 530, in __bootstrap_inner
File "/usr/lib/python2.7/site-packages/paramiko/transport.py", line 1574, in run : 'NoneType' object has no attribute 'error'
Il programma che ho scritto è la seguente: -
class Session:
def __init__(self, ipaddr, username, password):
self.ipaddr = ipaddr
self.username = username
self.password = password
self.connect()
def connect(self):
try:
time.sleep(1)
self.ssh = paramiko.SSHClient()
self.ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
try:
self.ssh.connect(self.ipaddr, username=self.username, password=self.password)
time.sleep(2)
except socket.error, e:
print e
self.ssh.close()
sys.exit()
except Exception, e:
print e
def executeCmd(self, cmd):
data = ""
try:
stdin, stdout, stderr = self.ssh.exec_command(cmd)
data = stdout.read()
except SSHException, e:
print "Error: ", e
errorMsg = "Error: %s" %traceback.format_exc()
print errorMsg
return data
def __del__(self):
self.ssh.close()
come risolvere questa eccezione? Per favore aiuto.
Grazie
Sembra che questo è un duplicato di questa domanda: http://stackoverflow.com/questions/1745232/solving-thread-cleanup-on-paramiko ma il titolo di questa domanda è meglio – ifischer
bug relativo a Launchpad (nuovo e non assegnato) qui: https://bugs.launchpad.net/paramiko/+bug/786808 – ifischer
Bug relativo in Python Tracker: http://bugs.python.org/issue1722344, bug correlato in Paramiko-Github: https : //github.com/paramiko/paramiko/issues/17 – ifischer