Terminating a long command and continue the script
Probably you could make use of Timer from threading module (https://docs.python.org/3/library/threading.html) . This is simple example:
import subprocess
import threading
def terminate(process):
print('terminating process',process)
process.kill()
print('done')
cmd = [<your command>, <your arguments>,...]
process = subprocess.Popen(
cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
kill_timer = threading.Timer(1, terminate, [process])
try:
kill_timer.start()
stdout, stderr = process.communicate()
print(stdout, stderr)
finally:
kill_timer.cancel()
It should work on windows machine.