taskqueue and non-idempotent tasks

百般思念 提交于 2020-01-25 00:59:06

问题


I'm working on a voting app, where the user can upload a list of email addresses for all of the voters. After doing some error checking, I create a Voter entity for each voter. Since there can be a large number of voters, I create the Voter entities in a taskqueue to avoid the 30 second limit and the task looks like this:

    put_list = []
    for email, id in itertools.izip(voter_emails, uuids):
        put_list.append(Voter(election = election,
                              email = email,
                              uuid = id))
    election.txt_voters = ""
    put_list.append(election)
    db.put(put_list)

This task, however, isn't idempotent. Is there a way to make this task idempotent? Or is there a better way to do this?


回答1:


use a key_name rather than a uuid property to prevent creating duplicate voter entities.



来源:https://stackoverflow.com/questions/6719989/taskqueue-and-non-idempotent-tasks

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!