- Killing the subprocesses launched in both
_local_async_exec and _local_async_exec_pipe methods if cancelled
Change-Id: I89d15fa20246407f8e5942960151b1265ec2d298
Signed-off-by: Pedro Escaleira <escaleira@av.it.pt>
return output, return_code
except asyncio.CancelledError:
return output, return_code
except asyncio.CancelledError:
+ # first, kill the process if it is still running
+ if process.returncode is None:
+ process.kill()
raise
except K8sException:
raise
raise
except K8sException:
raise
try:
async with self.cmd_lock:
read, write = os.pipe()
try:
async with self.cmd_lock:
read, write = os.pipe()
- await asyncio.create_subprocess_exec(
+ process_1 = await asyncio.create_subprocess_exec(
*command1, stdout=write, env=environ
)
os.close(write)
*command1, stdout=write, env=environ
)
os.close(write)
return output, return_code
except asyncio.CancelledError:
return output, return_code
except asyncio.CancelledError:
+ # first, kill the processes if they are still running
+ for process in (process_1, process_2):
+ if process.returncode is None:
+ process.kill()
raise
except K8sException:
raise
raise
except K8sException:
raise