On Jan 18, 5:39 pm, ae <ae88...@gmail.com> wrote:
> How do people deal with controller functions that take a long time?

1) If you must do something that takes time, start it as a separate
process, and that process toggles a flag that says the job is
complete.  The user can be notified of the completion via email.  This
is only really worthwhile for longer jobs, say of the order of 5
minutes and longer.

2) If you must do something that takes time, but not so much time that
asking the user to go away and come back later would seem overkill,
then use an ajax function to poll the job status.  Yes, it is
laborious.  No, there isn't another way, unless that other way is to
use a library that simplifies doing this exact thing.

> In the past, I've handed requests off to another server (written on
> Twisted) and had javascript poll for status, but this is a bit
> laborious.

I suggest you present some code to this group that shows how laborious
it is, and ask for simplifications.  I am not a javascript guru, but
some do lurk here and that would be the best way to make it less
laborious.  web2py itself does have some helpers that make setting up
the javascript a little easier, such as the URL function and whatnot.
There may be more tricks that we could learn.

Reply via email to