File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change 1- from pssh import ParallelSSHClient
1+ from pssh . clients import ParallelSSHClient
22import datetime
33
44output = []
55host = 'localhost'
6- hosts = [host ]
6+ hosts = [host , host ]
77client = ParallelSSHClient (hosts )
88
99# Run 10 five second sleeps
10- cmds = ['sleep 5' for _ in xrange (10 )]
10+ cmds = ['sleep 5; uname ' for _ in range (10 )]
1111start = datetime .datetime .now ()
1212for cmd in cmds :
1313 output .append (client .run_command (cmd , stop_on_errors = False ))
1717start = datetime .datetime .now ()
1818for _output in output :
1919 client .join (_output )
20- print (_output )
20+ for host_out in _output .values ():
21+ for line in host_out .stdout :
22+ print (line )
23+ for line in host_out .stderr :
24+ print (line )
25+ print (f"Exit code: { host_out .exit_code } " )
2126end = datetime .datetime .now ()
2227print ("All commands finished in %s" % (end - start ,))
You can’t perform that action at this time.
0 commit comments