Not entirely in gevent, but I'd typically do this with an external queue of
some sort (redis or other) and some worker processes which consume jobs from
that queue -- your view function would put work into the queue in that case.
This is doubly good if the heavy work you're doing is at all cpu-bound.
m
On Sat, Jul 21, 2012 at 01:57:56PM -0700, dsfdf wrote:
> I posted on stackoverflow. But no one can answer so let me try here:
>
http://stackoverflow.com/questions/11594358/how-to-spawn-for-a-different-function-after-the-first-one-finishes-using-gevent
>
> The basic idea is as follows:
>
> a request comes to views1 and it first returns the username.
> There is some heavy job separate done by do_something_else right
> after views1 is done. You can think of this as creating a new
> user, but has to do some heavy checking on the background.
>
> def views1(..):
> username = get_uername(...)
> return username
> This is a
> favorite from lib import do_something_else
> question def do_something_else(...):
> (click // do heavy stuff here
> again to
> undo) gevent.joinall([
> gevent.spawn(views1, parmeter1, parmeter2, ...),
> gevent.spawn(do_something_else, parmeter1, parmeter2, ...)
> ])
>
> The problem is I don't think do_something_else was ever called
> based on my logging. I read tutorial and I don't know where to
> place gevent.sleep(0). I don't want blocking. I want the user
> sees the username right away, and let do_something_else runs in
> the background.
>
> Any idea?
--
Matt Billenstein
ma...@vazor.com
http://www.vazor.com/