rad
rad copied to clipboard
#爬虫爬着爬着就自己停了
#爬虫爬着爬着就自己停了
多给点细节,要不我认为是爬虫太累了。
【Python】Subprocess超时杀干净子进程【原创】.md_一直加班的程序猿-CSDN博客_python subprocess 超时 https://blog.csdn.net/jiandanokok/article/details/104853593/
p = subprocess.Popen(cmd_string, stderr=subprocess.STDOUT, start_new_session=True) format = 'gbk' try: (msg, errs) = p.communicate(timeout=timeout) ret_code = p.poll() if ret_code: code = 1 msg = "[Error]Called Error : " + str(msg.decode(format)) else: code = 0 msg = str(msg.decode(format)) except subprocess.TimeoutExpired: p.kill() p.terminate()