가능한 중복 :
subprocess with timeout
Best way to launch a process and block until it is finishedPython - X 초 후에 프로세스를 종료하고 파이썬 코드의 실행을 계속하려면 어떻게해야합니까?
나는 내가 좋아하는 리눅스 명령을 실행해야 파이썬 코드가 "컬 --user을 ...". 이 명령을 3600 초 동안 실행해야합니다. 3600 초 후에 "Linux 명령 프로세스"를 중단해야합니다. 내가 어떻게 이럴 수 있니?
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"
"process = os.system (command)"을 죽이는 방법에 대한 단서가 있습니까?
최고 감사합니다,