开发者

taskqueue and non-idempotent tasks

开发者 https://www.devze.com 2023-03-20 15:48 出处:网络
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 lar

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开发者_如何学Go way to make this task idempotent? Or is there a better way to do this?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号