I have the following snippet to run a task and terminate it if a timeout is exceeded.
try:
process = subprocess.run(
[
node_path,
render_puppeteer_path,
task.url,
tempdir,
],
capture_output=True,
check=False,
text=True,
timeout=TIMEOUT,
)
except subprocess.TimeoutExpired:
delete_dir(tempdir)
return Box(
success=False,
task=task,
data=dict(reason='timeout'),
)
My problem is that children of the running process is not cleared up after a timeout. How can I modify it such that they are cleared up?