Skip to content

Commit 433bab1

Browse files
author
Dan
committed
Added workaround for exit code being available for remote commands that exit immediately
1 parent de75c7b commit 433bab1

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

pssh/ssh_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ def exec_command(self, command, sudo=False, user=None, **kwargs):
229229
logger.debug("Running command %s on %s", command, self.host)
230230
channel.exec_command(command, **kwargs)
231231
logger.debug("Command started")
232-
gevent.sleep(0)
232+
gevent.sleep(.2)
233233
return channel, self.host, stdout, stderr
234234

235235
def _read_output_buffer(self, output_buffer, prefix=''):

tests/test_pssh_client.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,9 @@ def test_pssh_client_exec_command(self):
7070
msg="No output for host")
7171
self.assertTrue(output[self.host]['exit_code'] == 0)
7272

73-
def test_pssh_client_no_stdout_non_zero_exit_code(self):
73+
def test_pssh_client_no_stdout_non_zero_exit_code_immediate_exit(self):
7474
output = self.client.run_command('exit 1')
7575
expected_exit_code = 1
76-
self.client.join(output)
7776
exit_code = output[self.host]['exit_code']
7877
self.assertEqual(expected_exit_code, exit_code,
7978
msg="Got unexpected exit code - %s, expected %s" %
@@ -113,9 +112,9 @@ def test_pssh_client_run_command_get_output(self):
113112
expected_exit_code = 0
114113
expected_stdout = [self.fake_resp]
115114
expected_stderr = []
115+
exit_code = output[self.host]['exit_code']
116116
stdout = list(output[self.host]['stdout'])
117117
stderr = list(output[self.host]['stderr'])
118-
exit_code = output[self.host]['exit_code']
119118
self.assertEqual(expected_exit_code, exit_code,
120119
msg="Got unexpected exit code - %s, expected %s" %
121120
(exit_code,

0 commit comments

Comments
 (0)