Skip to content

Commit 446c9f0

Browse files
committed
Separate wait_for_completion from wait_for_output in the create_process method.
The wait_for_completion flag is now properly observed, and will poll the backend Live Response session until the command is completed, even if wait_for_output is set to False.
1 parent 2fd4a79 commit 446c9f0

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/cbapi/live_response_api.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,8 @@ def create_process(self, command_string, wait_for_output=True, remote_output_fil
296296
Reply from 192.168.1.1: bytes=32 time<1ms TTL=64
297297
298298
:param str command_string: command string used for the create process operation
299-
:param bool wait_for_output: Block on output from the new process (execute in foreground)
299+
:param bool wait_for_output: Block on output from the new process (execute in foreground). This will also set
300+
wait_for_completion (below).
300301
:param str remote_output_file_name: The remote output file name used for process output
301302
:param str working_directory: The working directory of the create process operation
302303
:param int wait_timeout: Time out used for this live response command
@@ -311,6 +312,9 @@ def create_process(self, command_string, wait_for_output=True, remote_output_fil
311312
# - get the temporary file from the endpoint
312313
# - delete the temporary file
313314

315+
if wait_for_output:
316+
wait_for_completion = True
317+
314318
data = {"name": "create process", "object": command_string, "wait": wait_for_completion}
315319

316320
if wait_for_output and not remote_output_file_name:
@@ -326,16 +330,19 @@ def create_process(self, command_string, wait_for_output=True, remote_output_fil
326330
resp = self._lr_post_command(data).json()
327331
command_id = resp.get('id')
328332

329-
if wait_for_output:
333+
if wait_for_completion:
330334
self._poll_command(command_id, timeout=wait_timeout)
331335

336+
if wait_for_output:
332337
# now the file is ready to be read
333338

334339
file_content = self.get_file(data["output_file"])
335340
# delete the file
336341
self._lr_post_command({"name": "delete file", "object": data["output_file"]})
337342

338343
return file_content
344+
else:
345+
return None
339346

340347
def list_processes(self):
341348
"""

0 commit comments

Comments
 (0)