Skip to content

Commit 8731379

Browse files
author
Dan
committed
Updated documentation
1 parent fcf596a commit 8731379

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

pssh/pssh_client.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,17 @@ def __init__(self, hosts,
9494
9595
>>> from pssh.pssh_client import ParallelSSHClient
9696
>>> from pssh.exceptions import AuthenticationException, \
97-
UnknownHostException, ConnectionErrorException
97+
UnknownHostException, ConnectionErrorException
9898
9999
>>> client = ParallelSSHClient(['myhost1', 'myhost2'])
100100
>>> try:
101101
>>> ... output = client.run_command('ls -ltrh /tmp/aasdfasdf', sudo=True)
102102
>>> except (AuthenticationException, UnknownHostException, ConnectionErrorException):
103103
>>> ... pass
104104
105-
>>> # Commands have started executing at this point
106-
>>> # Exit code will not be available immediately
105+
Commands have started executing at this point.
106+
Exit code(s) will not be available immediately.
107+
107108
>>> print output
108109
109110
::
@@ -137,9 +138,11 @@ def __init__(self, hosts,
137138
138139
Retrieve exit codes after commands have finished as below.
139140
141+
``exit_code`` in ``output`` will be ``None`` if command has not yet finished.
142+
140143
`parallel-ssh` starts commands asynchronously to enable running multiple
141144
commands in parallel without blocking.
142-
145+
143146
Because of this, exit codes will not be immediately available even for
144147
commands that exit immediately.
145148
@@ -152,7 +155,11 @@ def __init__(self, hosts,
152155
is necessary to cause `parallel-ssh` to wait for commands to finish and
153156
be able to gather exit codes.
154157
155-
``exit_code`` in ``output`` will be ``None`` if command has not yet finished.
158+
Either iterating over stdout/stderr or `client.join(output)` will cause exit
159+
codes to be available in output without explicitly calling `get_exit_codes`.
160+
161+
`client.pool.join()` does not update output and will need a call to
162+
`get_exit_codes` as shown below.
156163
157164
``get_exit_codes`` is not a blocking function and will not wait for commands
158165
to finish. Use ``client.join(output)`` to block until all commands have
@@ -222,11 +229,11 @@ def run_command(self, *args, **kwargs):
222229
"""Run command on all hosts in parallel, honoring self.pool_size,
223230
and return output buffers.
224231
225-
This function will block until all commands have **started** and
226-
then return immediately.
232+
This function will block until all commands been *sent* to remote servers
233+
and then return immediately.
227234
228235
Any connection and/or authentication exceptions will be raised here
229-
and need catching _unless_ `run_command` is called with
236+
and need catching *unless* `run_command` is called with
230237
`stop_on_errors=False`.
231238
232239
:param args: Positional arguments for command

0 commit comments

Comments
 (0)