You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -65,15 +63,34 @@ Run ``uname`` on two remote hosts in parallel.
65
63
Linux
66
64
Linux
67
65
66
+
67
+
Single Host Client
68
+
*******************
69
+
70
+
Single host client with similar API for users that do not need parallel functionality.
71
+
72
+
.. code-block:: python
73
+
74
+
from pssh.clients import SSHClient
75
+
76
+
host ='localhost'
77
+
cmd ='uname'
78
+
client = SSHClient(host)
79
+
80
+
host_out = client.run_command(cmd)
81
+
for line in host_out.stdout:
82
+
print(line)
83
+
84
+
68
85
**************
69
86
Native clients
70
87
**************
71
88
72
-
Starting from version ``1.2.0``, the default client in ``parallel-ssh`` has changed to a native client based on ``ssh2-python`` - ``libssh2`` C library - which offers much greater performance and reduced overhead compared to other Python SSH libraries.
89
+
The default client in ``parallel-ssh`` is a native client based on ``ssh2-python`` - ``libssh2`` C library - which offers much greater performance and reduced overhead compared to other Python SSH libraries.
73
90
74
91
See `this post <https://parallel-ssh.org/post/parallel-ssh-libssh2>`_ for a performance comparison of different Python SSH libraries.
75
92
76
-
An alternative client based on ``ssh-python`` (``libssh``) is also available. See `client documentation <http://parallel-ssh.readthedocs.io/en/latest/clients.html>`_ for a feature comparison of the available clients in the library.
93
+
Alternative clients based on ``ssh-python`` (``libssh``) are also available under ``pssh.clients.ssh``. See `client documentation <http://parallel-ssh.readthedocs.io/en/latest/clients.html>`_ for a feature comparison of the available clients in the library.
77
94
78
95
``parallel-ssh`` makes use of clients and an event loop solely based on C libraries providing native code levels of performance and stability with an easy to use Python API.
79
96
@@ -84,15 +101,15 @@ Native Code Client Features
84
101
85
102
* Highest performance and least overhead of any Python SSH library
86
103
* Thread safe - makes use of native threads for CPU bound calls like authentication
87
-
* Natively non-blocking utilising ``libssh2`` via ``ssh2-python``
104
+
* Natively asynchronous utilising ``libssh2`` via ``ssh2-python``
88
105
* Significantly reduced overhead in CPU and memory usage
89
106
90
107
91
108
***********
92
109
Exit codes
93
110
***********
94
111
95
-
Once *either* standard output is iterated on *to completion*, or ``client.join(output, consume_output=True)`` is called, exit codes become available in host output.
112
+
Once *either* standard output is iterated on *to completion*, or ``client.join()`` is called, exit codes become available in host output.
96
113
97
114
Iteration ends *only when remote command has completed*, though it may be interrupted and resumed at any point.
98
115
@@ -126,23 +143,22 @@ After ``join`` returns, commands have finished and all output can be read withou
126
143
127
144
.. code-block:: python
128
145
129
-
client.join(output)
146
+
client.join()
130
147
131
148
for host_out in output:
132
149
for line in host_output.stdout:
133
150
print(line)
134
151
print(host_out.exit_code)
135
152
136
-
Similarly, exit codes are available after ``client.join(output, consume_output=True)``.
153
+
Similarly, exit codes are available after ``client.join()`` without reading output.
137
154
138
-
``consume_output`` flag must be set to get exit codes when not reading from ``stdout``. Future releases aim to remove the need for `consume_output` to be set.
139
155
140
156
.. code-block:: python
141
157
142
158
output = client.run_command('uname')
143
159
144
160
# Wait for commands to complete and consume output so can get exit codes
Copy file name to clipboardExpand all lines: doc/quickstart.rst
+3-3
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ Examples all assume a valid key is available on a running SSH agent. See `Progra
17
17
Complete Example
18
18
-----------------
19
19
20
-
Host list can contain identical hosts. Commands are executed concurrently on every host given to the client regardless.
20
+
Host list can contain identical hosts. Commands are executed concurrently on every host given to the client regardless, up to pool size.
21
21
22
22
.. code-block:: python
23
23
@@ -45,7 +45,7 @@ Output:
45
45
Single Host Client
46
46
====================
47
47
48
-
``parallel-ssh`` has a fully featured, non-blocking single host client that it uses for all its parallel commands.
48
+
``parallel-ssh`` has a fully featured, asynchronous single host client that it uses for all its parallel commands.
49
49
50
50
Users that do not need the parallel capabilities can use the single host client for a simpler way to run asynchronous non-blocking commands on a remote host.
0 commit comments