Do not use threads for background processes. Use an actual seperate process
python web2py.py -S app -M -R applications/app/private/ process_script.py You can have it start by web2py cron On Apr 28, 11:30 am, Jose <[email protected]> wrote: > Hello, > > I am developing a web application that contains at least three > sections with high processing load (migration, conversion and > calculations). My idea is that when you call these processes, is made > in the background or in a separate thread, so that the user can > continue "using" the application while still running the "process" > behind. > > My first approach was to use threading.Thread, but I think it was not > a good idea. > > in mimodulo.py: > > class Mi_Clase(threading.Thread): > def __init__(self): > threading.Thread.__init__(self) > > def procesar(self): > #proceso... > > def run(self): > self.procesar() > > in the controller default.py: > def procesar(): > modulo = local_import('mimodulo', reload=True) > t = modulo.Mi_Clase() > t.start() > #t.join() > redirect(URL(...)) > > the problem is that when the redirect occurs (...), the thread is > closed and the process is short. > > How should I solve this? > > In principle I do not care to know is happening in the thread, but it > can be better. At the end of processing in the thread, send an email > notifying them of the outcome of the process. > > According to the size of what you have to process, it may take several > minutes to several hours. Is correct to do this in the context of a > web application? > > Regards, > Jose

