thanks howesc


On 11 Mar 2011, at 23:29, howesc <[email protected]> wrote:

> i use taskqueue extensively in my GAE apps.  i have not wrapped it in a way 
> that it runs in non-gae environment.  My usages of the taskqueue are for 
> things that i can't complete in a single 30 second execution time, so i 
> suppose i could put an 'if not GAE run all the processing in one request' 
> type statement.
> 
> my usual usage pattern (i have a few variations on this, but this is a simple 
> example):
> 
>  
> def process_lots_of_rows():
>     from google.appengine.api import taskqueue
> 
>     last_timestamp = request.vars.last_timestamp or 
> datetime.datetime(2010,1,1) #reasonable default for my app
>     limit = 100
>     #get records.  use >= so i don't miss any, don't use ID as they are not 
> assigned in strictly increasing fashion
>     rows = db(db.record.created_time >= 
> last_timestamp).select(orderby=db.end_user.timestamp,
>                                              limitby=(0,limit))
> 
>     for r in rows:
>         r.update_record(bob='fred')
> 
>     if len(rows) == limit:
>         #there are probably more to process
>         taskqueue.add(url=URL(r=request))
>     
>     return dict(message="did some work")
> 

Reply via email to