我有一个流程,该流程在如下所示的for循环中调用很多数据:
我使用python下载所有这些数据,并且这个过程一直在运行。我的问题是这样的:我的python脚本是否可以“记住”发生错误时调用的最后一个字符对象?我的脚本在循环上运行,如果有错误,它将重新启动,但是会从循环的开头而不是它调用的最后一个字符重新开始。
这里有一些伪代码来说明我在做什么:
async def update_characters(parent):
get_characters = "{api-url}"
res = _get_characters_response(get_characters)
for character in res: # if error remember this character object
member_id = character['membershipId']
character_id = character['characterId']
activity_history = await _get_api_response(parent.api.get_activity_history, 4, member_id, character_id, 15,
0, 0)
if len(activity_history['Response']) == 0:
print("No activity history for " + str(character['characterName']
+ " (" + str(character_id) + ")"))
continue
else:
for act in activity_history['Response']['activities']:
activity_url = "{insert_activity_url}"