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 <arksine.code@gmail.com>
This commit is contained in:
Arksine 2021-03-06 19:20:48 -05:00
parent dc165636cb
commit 44f1147f71
1 changed files with 3 additions and 7 deletions

View File

@ -105,18 +105,14 @@ class ShellCommand:
async def run(self, timeout=2., verbose=True): async def run(self, timeout=2., verbose=True):
self.return_code = self.proc = None self.return_code = self.proc = None
self.cancelled = False self.cancelled = False
if timeout is None: if not timeout:
# Never timeout # Never timeout
timeout = 9999999999999999. timeout = 9999999999999999.
if not timeout or self.output_cb is None: if self.std_out_cb is None and self.std_err_cb is None:
# Fire and forget commands cannot be verbose as we can't # No callbacks set so output cannot be verbose
# clean up after the process terminates
verbose = False verbose = False
if not await self._create_subprocess(): if not await self._create_subprocess():
return False return False
if not timeout:
# fire and forget, return from execution
return True
try: try:
if verbose: if verbose:
ret = self.proc.communicate_with_cb() ret = self.proc.communicate_with_cb()