I've been reading and trying to figure out the best way to implement 
scheduled background tasks in PythonAnywhere. I think I understand the 
basics and challenges, but I still think I'm missing something.

I haven't found a reasonable way to use web2py scheduler directly in 
PythonAnywhere. Is it possible? When using script with my own loop, I'm 
having either issues with timeout (might take several minutes before I 
check db again) or when manually refreshing DAL with auto_import=True, the 
db variables are not imported, only table names (I have few pickle filters).

I want to have a background task, which checks the database and sends 
emails if necessary. PythonAnywhere offers min 1 hour interval for scripts, 
and my script should be more responsive (varies from 30 seconds to 15 
minutes).

Currently I've made an hourly scheduled python script, which never ends 
(while loop), checks the database and then sleep variable time, if nothing 
is found. It updates a file so that when PythonAnywhere tries to start a 
new process again (hourly), it will not start another instance as the 
previous script is still ok. 

This works fine and I use the web2py environment to load all model 
information and so on (e.g. python web2py.py -S app -M -R 
applications\app\modules\script.py). But that command loads the models only 
once and if I sleep 15 minutes, the db connection is lost. I tried to 
search if web2py has something like db.reconnect() by could'nt found 
anything.

P.s. I do have to say that PythonAnywhere rocks for a small developer like 
my (as well as we2py).

Ykä

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to