I use python 2.7.12 and newest paramiko 2.0.2, and run a script which ssh login many linux server concurrently.
sometimes it runs very well, but sometimes it will report the following weird error:
**no handers could be found for logger 'paramiko.transport'
.....
Exception in thread Thread-2
.....
.....
RequirementParseError invalid requirement parse error at ''**
the script is shown in below:
anybody can help me?
Thanks in advance with for any help.
#! ~/python2.7.12/bin/python import paramiko import threading def ssh2(ip,username,passwd,cmd): try: ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect(ip,22,username,passwd,timeout=5) for m in cmd: stdin, stdout, stderr = ssh.exec_command(m) out = stdout.readlines() for o in out: print o, print '%s\tOK\n'%(ip) ssh.close() except : print '%s\tError\n'%(ip) if __name__=='__main__': cmd = ['uptime','free -g'] username = "usera" passwd = "wordad" threads = [] print "Begin......" for i in range(10,154): ip = '10.16.2.'+str(i) a=threading.Thread(target=ssh2,args=(ip,username,passwd,cmd)) threads.append(a) for i in threads: i.start() for i in threads: i.join()
Asked
Active
Viewed 874 times
0

user1102185
- 33
- 7
1 Answers
0
This workaround worked for me. Change from a
concurrent.futures.ThreadPoolExecutor
to a:
concurrent.futures.ProcessPoolExecutor

tleyden
- 1,942
- 2
- 12
- 17