Error in scheduler

71 views
Skip to first unread message

Aydin S

unread,
May 20, 2015, 3:25:31 PM5/20/15
to web...@googlegroups.com

When I try to create a new model in web2py for scheduller I get an error. The model is as follows

`def f():
    a = 2
    return ()

from gluon.scheduler import Scheduler scheduler = Scheduler(db,dict(our_function=f))

I get the following error:

`

Traceback (most recent call last):
 File "/home/www-data/web2py/gluon/restricted.py", line 227, in restricted
 exec ccode in environment
 File "/home/www-data/web2py/applications/Home_Lights/models/mtasks.py", line             `42, in <module>`
 Scheduler(db,dict(our_function=f))
 File "/home/www-data/web2py/gluon/scheduler.py", line 587, in __init__
 self.define_tables(db, migrate=migrate)
 File "/home/www-data/web2py/gluon/scheduler.py", line 655, in define_tables
 format='%(task_name)s')
 File "/home/www-data/web2py/gluon/packages/dal/pydal/base.py", line 799, in  `define_table`
 raise SyntaxError('table already defined: %s' % tablename)

    SyntaxError: table already defined: scheduler_task`

I suspect it has to do with the execution permission of the newly created model. any help is appreciated...?

Massimiliano

unread,
May 21, 2015, 2:57:53 AM5/21/15
to web...@googlegroups.com
Just set:

migrate=False

so it doesn't try to recreate the table

from gluon.scheduler import Scheduler scheduler = Scheduler(db,tasks=dict(our_
function=f), migrate=False)


--
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+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Massimiliano

Aydin S

unread,
May 21, 2015, 10:47:12 PM5/21/15
to web...@googlegroups.com
Thanks for the response, it gives the same response.

In general what's the right way to define more than one scheduled tasks?
I have tried both the following and non worked:
1- Create to models and define each function in there (and set migrate=False)
2- Define two functions in the same model (and set migrate=False)
Reply all
Reply to author
Forward
0 new messages