开发者

taskqueue and non-idempotent tasks

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜