我正在以以下方式运行python脚本:
python3 /home/ubuntu/...
代码的最后一行是:
def getdata3(...)
...
datarALL = []
responsedata = requests.get(url, data=data, headers=hed, verify=False)
if responsedata.status_code == 200: # 200 for successful call
responsedata = responsedata.text
jsondata = json.loads(responsedata)
if "results" in jsondata:
if jsondata["results"]:
datarALL.extend(jsondata["results"])
print ("{1} page {0} finished".format(page,str(datetime.now())))
return datarALL
def processData(...)
....
result= []
with ThreadPoolExecutor(max_workers=num_of_pages) as executor:
futh = [(executor.submit(self.getdata3, page, hed, data, apifolder,additional)) for page in pages]
for data in as_completed(futh):
result.extend(data.result())
print ("Finished generateing data.")
return result
if __name__ == '__main__':
processData(...)
...
print ("done")
在控制台上,我看到:
done
[2]+ Killed python3 /home/ubuntu/....
屏幕:
为什么我的脚本在执行最后一条命令后被杀死?
我应该注意:Killed不会出现在每次运行的代码中,这就是为什么我无法找出问题的原因。