minou
minou

Reputation: 16563

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 way to make this task idempotent? Or is there a better way to do this?

Upvotes: 1

Views: 506

Answers (1)

Chris Farmiloe
Chris Farmiloe

Reputation: 14185

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

Upvotes: 1

Related Questions