Spawning processes takes extra memory. If the user reloads the page too many time to soon get an out of memory. I think it i better to have a single background process that handles tasks via a queue. It is described in the book chapter 4.
On Sep 22, 11:12 am, José Luis Redrejo <[email protected]> wrote: > > On 8 sep 2009, 07:36, mdipierro <[email protected]> wrote: > >> Not elegant but you can do this... > > >> def index(): > >> import subprocess > >> subprocess.Popen('python web2py.py -S yourapp -M -S > >> yourscript.py') > >> do something else > > why is it not elegant? > I only can find of doing this using a queue run by cron, as you > suggested > inhttp://groups.google.com/group/web2py/browse_thread/thread/5b682d1b12... > What would a more elegant solution would be? > > This is a kind of problem many applications will have when they are > not pure web applications, but web interfaces to do something that > requires running (and, often, wait for) tasks that can take a long > time to be executed. > > A better (an elegant) idea on how to solve to this kind of problem > would be great. > > Thanks. > José L. > > >> On Sep 7, 11:58 pm, Adi <[email protected]> wrote: > > >> > Nope. This requires running the conversion module independently from > >> > the command line. Any other help with this? > > >> > On Sep 4, 11:15 am, mdipierro <[email protected]> wrote: > > >> > > check if this does what you > >> > > need:http://www.web2py.com/appliances/default/show/38 > > >> > > Massimo > > >> > > On Sep 3, 11:34 pm, Adi <[email protected]> wrote: > > >> > > > Hi, > > >> > > > I'm new to web2py. I have this requirement - on loading a page, I > >> > > > want > >> > > > to trigger a backgroundprocessautomatically. Since theprocessis > >> > > > time-consuming, I don't want user to wait. > > >> > > > This is what I tried - running the backgroundprocessas a separate > >> > > > thread. This results in > > >> > > > ProgrammingError: Cannot operate on a closed database. > > >> > > > I read another thread with the same subject, it spoke of "refreshing > >> > > > the value of DB in environment dictionary". How can I do that? And > >> > > > why > >> > > > do I need to do it? > > >> > > > What is the better way to achieve what I want? > >

