Hi all

I was trying this example below,  because we are searching for some 
mechanism to run  batch jobs in parallel

But it seems to me that two requests of the same user have the result of 
putting the jobs in 
the same queue instead of running in parallel.
Is this correct ? Do i miss something ?
Is there a way to run batch jobs in parallel using asyncjob or other 
methods (thread, gevent, ...)

Some hints or ideas 
Regards gio

class Globals(object):
    def __init__(self):
        start_async_worker()



from tgext.asyncjob import asyncjob_perform, asyncjob_get_progress, 
asyncjob_set_progress

@expose()
def controller_method(self):
    def async_action():
        for i in range(5):
            asyncjob_set_progress(i)
            time.sleep(1)

    taskid = asyncjob_perform(async_action)
    return redirect(url('/state', uid=taskid))

@expose()
def state(self, uid):
    state = asyncjob_get_progress(uid)
    if not state:
        return 'Job Completed'
    elif state[0] < 0:
        return 'Not yet started'
    else:
        return str(state[0])

-- 
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/turbogears.
For more options, visit https://groups.google.com/d/optout.

Reply via email to