hi robert, even with your approach i would need to keep track of what already is in the queue.
lets say the tasks are deleting (or even updating) the cache on the occurrence of a specific event because the cached values wouldnt reflect the actual datastore situation. if 50 events happen within one minute without naming them i would need to add 50 tasks which are doing exacltly the same stuff. the events are independent from each other and not regular in time. maybe for 10h no event happens and then there are 10 concurrent within a second. setting a value in the datastore is too expensive and not worth. doing it in memcache would be fast but not reliable enough. On Nov 5, 2010, at 12:03 AM, Robert Kluin wrote: > Hi Andreas, > So you are trying to keep a task from simultaneously executing > multiple times? One thing to note is that, even with names, it is > possible for a task to simultaneously run more than once. > > If possible I would suggest 'keying' the task names. So if you are > currently trying to start a task named 'do-some-stuff', the next run > would be 'do-some-stuff-2', and so on. You can tell if a task is > sitting in the queue versus already run by the exception raised: > TaskAlreadyExists indicates it is on the queue, TombstonedTask > indicates it has already run. > http://code.google.com/appengine/docs/python/taskqueue/exceptions.html > > Without knowing what / how the tasks are generated it is hard to > suggest much more. > > > > > Robert > > > > > On Wed, Nov 3, 2010 at 08:11, andreas schmid <[email protected]> wrote: >> my usecase is: >> - add a task in the queue, its not in there yet so it gets added >> - another process needs to add a task with the same logic, it finds the task >> (which didnt run) already in queue and returns. >> - the task runs. >> - another process adds this task again.... >> >> what i want to achieve is to avoid having a task twice in a queue. i tried >> setting names based on datetime objects but but the only thing i get is that >> i cant add a task the same task the same minute or another time period. >> >> >> On Nov 2, 2010, at 11:38 PM, Robert Kluin wrote: >> >>> It is good that it is not possible. Otherwise you could not use this >>> feature to prevent fork bombs and you would need to implement the same >>> thing yourself. >>> >>> If you do not need that feature, do not name the task. Or, name the >>> task but if you get a tomb-stoned task error, increment the task's >>> name and try to enqueue it again. >>> >>> >>> >>> Robert >>> >>> >>> >>> >>> >>> >>> On Tue, Nov 2, 2010 at 10:49, andreas schmid <[email protected]> wrote: >>>> hi, >>>> >>>> >>>> i don't really understand why a task name has to be unique forever on my >>>> app. >>>> i think it would be a lot better if a task can be add to a queue if its >>>> not already in there and as soon as the task is done another process could >>>> add it again with the same name. >>>> >>>> or am i doing something wrong in my app and this is possible? >>>> >>>> -- >>>> You received this message because you are subscribed to the Google Groups >>>> "Google App Engine" group. >>>> To post to this group, send email to [email protected]. >>>> To unsubscribe from this group, send email to >>>> [email protected]. >>>> For more options, visit this group at >>>> http://groups.google.com/group/google-appengine?hl=en. >>>> >>>> >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Google App Engine" group. >>> To post to this group, send email to [email protected]. >>> To unsubscribe from this group, send email to >>> [email protected]. >>> For more options, visit this group at >>> http://groups.google.com/group/google-appengine?hl=en. >>> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Google App Engine" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/google-appengine?hl=en. >> >> > > -- > You received this message because you are subscribed to the Google Groups > "Google App Engine" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/google-appengine?hl=en. > -- You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.
