Err... don't do this like you did :) There are some "do's" and "don'ts" in the programming books and you've touched most of the "don'ts" with your code.
Use the scheduler: http://web2py.com/books/default/chapter/29/04#Scheduler You'll also most likely be using ajax to poll the database and check if the task has finished in order to make your front-end perform something. Once you have some code in place, don't hesitate to ask more questions if you get stuck. Sheduler has also been discussed a lot in the past, so the group's search will help you too. Regards On Monday, February 17, 2014 12:28:59 PM UTC+1, Robin Manoli wrote: > > Hey, I would like to create a background timer, and when it finishes I > would like web2py to do something. > > I have tried numerous ways to do this, without succeeding. The closest one > to success looked like this: > 1. import urllib; urllib.urlopen(url).read() # read url which is a php > script that calls a python script that sleeps > 2. url is a php script that calls a python script that sleeps inside thread > 3. the php script uses exec("/path/to/script.py &") which goes in the > background > 4. when I access the php url from my browser the web server answers > instantly, which is why I thought it would succeed > 5. when I access the php url from python/web2py however, as in the code > above, it waits until after the sleep, which causes a timeout > > Note that web2py is using apache webserver in my case. > > I have also tried to sleep inside a thread in web2py, calling the script > through a subprocess from web2py, but nothing has worked. > > Is there any way to run a web2py command after a customly chosen time? > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.

