Skip to content

Commit 109e173

Browse files
author
Dan
committed
Added join convenience function to parallel client and unittest
1 parent 57ed4d5 commit 109e173

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

pssh/pssh_client.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,15 @@ def _update_host_output(self, output, host, exit_code, channel, stdout, stderr,
387387
'stderr' : stderr,
388388
'cmd' : cmd,
389389
'exception' : exception,})
390-
390+
391+
def join(self, output):
392+
"""Block until all remote commands in output have finished
393+
and retrieve exit codes"""
394+
for host in output:
395+
for line in output[host]['stdout']:
396+
pass
397+
self.get_exit_codes(output)
398+
391399
def get_exit_codes(self, output):
392400
"""Get exit code for all hosts in output *if available*.
393401
Output parameter is modified in-place.

tests/test_pssh_client.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,7 @@ def test_pssh_client_long_running_command_exit_codes(self):
293293
# Embedded server is also asynchronous and in the same thread
294294
# as our client so need to sleep for duration of server connection
295295
gevent.sleep(expected_lines)
296-
client.pool.join()
297-
client.get_exit_codes(output)
296+
client.join(output)
298297
self.assertTrue(output[self.host]['exit_code'] == 0,
299298
msg="Got non-zero exit code %s" % (
300299
output[self.host]['exit_code'],))

0 commit comments

Comments
 (0)