From 44f1147f711d9c070620ae81d2bae7b8163f5d58 Mon Sep 17 00:00:00 2001 From: Arksine Date: Sat, 6 Mar 2021 19:20:48 -0500 Subject: [PATCH] shell_command: remove "fire and forget" functionality A consumer of shell command can achieve "fire and forget" by scheduling the future returned by "run()" to execute on the event loop. Signed-off-by: Eric Callahan --- moonraker/plugins/shell_command.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/moonraker/plugins/shell_command.py b/moonraker/plugins/shell_command.py index e3ff2a9..d00bee5 100644 --- a/moonraker/plugins/shell_command.py +++ b/moonraker/plugins/shell_command.py @@ -105,18 +105,14 @@ class ShellCommand: async def run(self, timeout=2., verbose=True): self.return_code = self.proc = None self.cancelled = False - if timeout is None: + if not timeout: # Never timeout timeout = 9999999999999999. - if not timeout or self.output_cb is None: - # Fire and forget commands cannot be verbose as we can't - # clean up after the process terminates + if self.std_out_cb is None and self.std_err_cb is None: + # No callbacks set so output cannot be verbose verbose = False if not await self._create_subprocess(): return False - if not timeout: - # fire and forget, return from execution - return True try: if verbose: ret = self.proc.communicate_with_cb()