@@ -94,16 +94,17 @@ def __init__(self, hosts,
94
94
95
95
>>> from pssh.pssh_client import ParallelSSHClient
96
96
>>> from pssh.exceptions import AuthenticationException, \
97
- UnknownHostException, ConnectionErrorException
97
+ UnknownHostException, ConnectionErrorException
98
98
99
99
>>> client = ParallelSSHClient(['myhost1', 'myhost2'])
100
100
>>> try:
101
101
>>> ... output = client.run_command('ls -ltrh /tmp/aasdfasdf', sudo=True)
102
102
>>> except (AuthenticationException, UnknownHostException, ConnectionErrorException):
103
103
>>> ... pass
104
104
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
+
107
108
>>> print output
108
109
109
110
::
@@ -137,9 +138,11 @@ def __init__(self, hosts,
137
138
138
139
Retrieve exit codes after commands have finished as below.
139
140
141
+ ``exit_code`` in ``output`` will be ``None`` if command has not yet finished.
142
+
140
143
`parallel-ssh` starts commands asynchronously to enable running multiple
141
144
commands in parallel without blocking.
142
-
145
+
143
146
Because of this, exit codes will not be immediately available even for
144
147
commands that exit immediately.
145
148
@@ -152,7 +155,11 @@ def __init__(self, hosts,
152
155
is necessary to cause `parallel-ssh` to wait for commands to finish and
153
156
be able to gather exit codes.
154
157
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.
156
163
157
164
``get_exit_codes`` is not a blocking function and will not wait for commands
158
165
to finish. Use ``client.join(output)`` to block until all commands have
@@ -222,11 +229,11 @@ def run_command(self, *args, **kwargs):
222
229
"""Run command on all hosts in parallel, honoring self.pool_size,
223
230
and return output buffers.
224
231
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.
227
234
228
235
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
230
237
`stop_on_errors=False`.
231
238
232
239
:param args: Positional arguments for command
0 commit comments