tgext.asyncjob questions

19 views
Skip to first unread message

solab solab

unread,
Mar 23, 2014, 11:43:30 AM3/23/14
to turbo...@googlegroups.com
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])

Alessandro Molina

unread,
Mar 24, 2014, 2:42:02 PM3/24/14
to TurboGears .
Yes, async_job has a single dispatch queue per process, you can achieve multiple queues by running multiple processes.


--
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 turbogears+...@googlegroups.com.
To post to this group, send email to turbo...@googlegroups.com.
Visit this group at http://groups.google.com/group/turbogears.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages