我在运行一个python脚本(下载器.py)在数据采集服务器的后台。它会浏览链接列表并下载每个图片。(下面的代码片段)由于有很多图像,我运行的是“nohup python”下载器.py&;“因为没有挂机,而且在后台。在
一切开始都很好,但是在任意数量的图像之后,图像停止下载。当我运行“ps aux | grep”时,进程PID仍然显示为正在运行的进程下载器.py“,但是不出来输出文件刚刚打印了下一个文件的链接,正如代码片段中的“print(myfile+”“+link)”所输出的那样。(没有错误消息显示在不出来,它只会停止下载或继续链接文件中的下一个图像)。有什么问题吗?unix中进程的“nice”优先级设置为0。在for link in read_lines("data_links/"+myfile):
try:
print(myfile + " " + link)
counter = counter + 1
##downloading the image and saving the file in data_collection/
print("set file structure for download")
f = open("data_collection/" + myfile.replace("_links.txt", "") + "/" + str(counter) + ".jpg", 'wb')
print("beginning url request")
f.write(request.urlopen(link).read())
print("url request done, closing file")
f.close()
print("done downloading, moving onto next")
except:
print("downloading error, but no problem, we're moving on to the next one")
continue