Skip to content

Commit c9ede18

Browse files
committed
#52 handle failed hosts better
Made ```join``` and ```get_exit_codes``` handle failed hosts gracefully when ```stop_on_errors=False``` is passed to run_command
1 parent 2317c2f commit c9ede18

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

pssh/pssh_client.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,10 @@ def join(self, output):
401401
"""Block until all remote commands in output have finished
402402
and retrieve exit codes"""
403403
for host in output:
404-
for line in output[host]['stdout']:
405-
pass
404+
stdout = output[host].get('stdout')
405+
if stdout:
406+
for _ in stdout:
407+
pass
406408
self.get_exit_codes(output)
407409

408410
def get_exit_codes(self, output):
@@ -429,7 +431,7 @@ def get_exit_code(self, host_output):
429431

430432
def _get_exit_code(self, channel):
431433
"""Get exit code from channel if ready"""
432-
if not channel.exit_status_ready():
434+
if not channel or not channel.exit_status_ready():
433435
return
434436
channel.close()
435437
return channel.recv_exit_status()

0 commit comments

Comments
 (0)