AttributeError: 'thread._local' object has no attribute '_scheduled'

1,073 views
Skip to first unread message

Brian M

unread,
Dec 28, 2011, 10:36:04 PM12/28/11
to web...@googlegroups.com
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

pbreit

unread,
May 15, 2012, 3:35:20 PM5/15/12
to web...@googlegroups.com
In order to avoid "NameError: name 'task_function' is not defined":

from gluon.scheduler import Scheduler
myscheduler = Scheduler(db, dict(task_name=None))
Reply all
Reply to author
Forward
0 new messages