I wan to implement a timeout on the child spawned by a subprocess call.
So as a test:
#!/home/depot/.conda/envs/python3/bin/python
import subprocess
if __name__ == "__main__":
subprocess.call('./sleep.py', timeout=1)
The sleep.py
file being run:
#!/home/depot/.conda/envs/python36/bin/python
from time import sleep
if __name__ =="__main__":
for j in range(3):
print(j)
sleep(1)
Now clearly this doesn't implement any timeout.
I was a bit surprised as the doc seems to suggest that timeout is indeed an option in:
Using the subprocess Module.
However other answers on SO seems to disregard that functionality and advocate for the creation of a custom made timer:
Subprocess timeout does not work
Using module 'subprocess' with timeout
How is it possible to implement a timeout with the builtin timeout
argument?