Skip to content

Commit

Permalink
Make Execute Command keyword executes for the duration of the actua…
Browse files Browse the repository at this point in the history
…l command if command is passing (#360)

Fixes #359
  • Loading branch information
cristii006 committed Sep 22, 2020
1 parent 83011b6 commit 1557ce0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions atest/execute_command.robot
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Resource resources/shell.robot
Suite Setup Login And Upload Test Scripts
Suite Teardown Remove Test Files And Close Connections
Library OperatingSystem WITH NAME OS
Library DateTime

*** Test Cases ***
Execute Timeout
Expand Down Expand Up @@ -101,3 +102,10 @@ Execute Command With Invoke Subsystem

Execute Command With Timeout
Run Keyword and Expect Error *Timed out in 5 seconds Execute Command sleep 10 timeout=5s

Execute Command In Certain Amount Of Time
${start_time}= Get Current Date result_format=%s exclude_millis=True
Execute Command for i in {1..3}; do echo "Command no. $i"; sleep 1; done timeout=5s
${end_time}= Get Current Date result_format=%s exclude_millis=True
${execution_time}= Subtract Time From Time ${end_time} ${start_time}
Should Be Equal As Numbers 3 ${execution_time}
2 changes: 2 additions & 0 deletions src/SSHLibrary/pythonclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,8 @@ def _flush_stdout_and_stderr(self, stderr_filebuffer, stderrs, stdout_filebuffer
if timeout:
end_time = time.time() + timeout
while time.time() < end_time:
if self._shell.status_event.wait(0):
break
self._output_logging(stderr_filebuffer, stderrs, stdout_filebuffer, stdouts, output_during_execution)
if not self._shell.status_event.isSet():
if is_truthy(output_if_timeout):
Expand Down

0 comments on commit 1557ce0

Please sign in to comment.