Possible Duplicate:
subprocess with timeout
Best way to launch a process and block until it is finished
I have a python code where I need to run a Linux command like "curl --user....". I need to run this command for 3600 seconds. After the 3600 seconds I need to kill the "Linux command process". How can I possibly do this?
def timeout_command(command, timeout):
import os, datetime, time, signal
start = datetime.datetime.now()
time_pass = 0
while (time_pass < timeout):
process = os.system(command)
now = datetime.datetime.now()
time_pass = (now-start).seconds
print time_pass
print timeout_command("curl --user...", 3600)
print "Other2"
print "Other3"
Any clues on how to kill this: "process = os.system(command)"?
Best Regards,