问题
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