shell_command: handle ProcessLookupError when cancelling
This suggests that the process has previously exited. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
e71e723f89
commit
4f43cf3a9f
|
@ -85,12 +85,14 @@ class SCProcess(asyncio.subprocess.Process):
|
|||
sig_idx = min(2, max(0, sig_idx))
|
||||
sigs = [signal.SIGINT, signal.SIGTERM, signal.SIGKILL][sig_idx:]
|
||||
for sig in sigs:
|
||||
self.send_signal(sig)
|
||||
try:
|
||||
self.send_signal(sig)
|
||||
ret = self.wait()
|
||||
await asyncio.wait_for(ret, timeout=2.)
|
||||
except asyncio.TimeoutError:
|
||||
continue
|
||||
except ProcessLookupError:
|
||||
pass
|
||||
logging.debug(f"Command '{self.program_name}' exited with "
|
||||
f"signal: {sig.name}")
|
||||
exit_success = True
|
||||
|
|
Loading…
Reference in New Issue