-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmuti_async.py
More file actions
29 lines (25 loc) · 778 Bytes
/
Copy pathmuti_async.py
File metadata and controls
29 lines (25 loc) · 778 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import multiprocessing
import sys,os,time
import getServerList
cmd = sys.argv[1]
result = []
def runCmd(h,port,user,passwd,command):
cmd = "python single_runCmd.py %s %s %s %s %s" %(h,port,user,passwd,command)
print cmd
os.system(cmd)
p = multiprocessing.Pool(processes=25)
#for i in range(1000):
# result.append(p.apply_async(run,('alex', 'hey')))
server_dic = getServerList.server_dic
#print server_dic
for host,values in server_dic.items():
ssh_port = values[0]
username = values[1]
password = values[2]
result.append(p.apply_async(runCmd,(host,ssh_port,username,password,cmd)))
#print p.apply_async(run,('hey Jude!',))
#print p.apply_async(run,('hey Alex',)).get()
p.close()
#p.join()
for res in result:
res.get(timeout=5)