任务队列和非幂等任务 [英] taskqueue and non-idempotent tasks
问题描述
我正在制作一个投票应用程序,用户可以在其中上传所有选民的电子邮件地址列表。在做了一些错误检查之后,我为每个选民创建了一个 Voter
实体。由于可以有大量的选民,我在任务队列中创建 Voter
个实体来避免30秒的限制,任务如下所示:
put_list = []
for email,id in itertools.izip(voter_emails,uuids):
put_list.append(Voter选举=选举,
电子邮件=电子邮件,
uuid = id))
election.txt_voters =
put_list.append(选举)
db.put(put_list )
然而,这项任务不是幂等的。有没有办法使这个任务幂等?还是有更好的方法来做到这一点?
使用key_name而不是uuid属性来防止创建重复的选举器实体。
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?
use a key_name rather than a uuid property to prevent creating duplicate voter entities.
这篇关于任务队列和非幂等任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!