In order to avoid "NameError: name 'task_function' is not defined":
from gluon.scheduler import Scheduler myscheduler = Scheduler(db, dict(task_name=None)) On Wednesday, December 28, 2011 7:36:04 PM UTC-8, Brian M wrote: > > This is simply a note for anybody else who may come across this error when > trying to run web2py's scheduler - it works just fine, provided you > actually set it up in your code. (As great as web2py is, it is not psychic) > > python web2py.py -K myapp > ... > AttributeError: 'thread._local' object has no attribute '_scheduled' > > If you get the error make sure you've actually imported the scheduler in > one of your app's models. > > from gluon.scheduler import Scheduler > myscheduler = Scheduler(db, dict(task_name = task_function)) > > I just wasted a bunch of time trying to figure out what was wrong only to > finally realize that I was trying to run the scheduler against the wrong > version of my app - one that I hadn't yet setup the scheduler in. DOH! I > hope that sharing my foolishness here might save someone else a bit of > frustration in the future. :) > > ~Brian >