scheduled task ignoring period

49 views
Skip to first unread message

James Holstead

unread,
Apr 25, 2017, 12:34:48 PM4/25/17
to web2py-users
I have a scheduler.py in my models directory with two functions, syncUsers, testAdd

# create scheduler
myScheduler = Scheduler(db, migrate=False, tasks=dict(myfunc=syncUsers))
     #myScheduler = Scheduler(db, migrate=False, tasks=dict(myfunc=testAdd)) 

# sync user task once a day
myScheduler.queue_task('myfunc', repeats=0, period=86400, timeout=1200, prevent_drift=True, immediate=True)

When I schedule testAdd, it executes once a day. When I schedule syncUsers it ignores the period argument, and repeats immediately.

testAdd simply returns 1, syncUsers loops through the user database and compares some fields with an external data source. 

Any ideas what is happening?


Dave S

unread,
Apr 25, 2017, 3:12:04 PM4/25/17
to web2py-users

What does syncUsers() return?

/dps
 

James Holstead

unread,
Apr 26, 2017, 9:09:30 AM4/26/17
to web2py-users
I've tried returning 0,1,2,None. It behaves the same regardless. There is only one user in my development database:

DEBUG:web2py.app.myapp:Found user: 123456789

DEBUG:web2py.app.myapp:    Updated.

DEBUG:web2py.app.myapp:    new task report: COMPLETED

DEBUG:web2py.app.myapp:   result: 1

DEBUG:web2py.app.myapp:Found user: 123456789

Dave S

unread,
Apr 26, 2017, 2:28:37 PM4/26/17
to web...@googlegroups.com


On Wednesday, April 26, 2017 at 6:09:30 AM UTC-7, James Holstead wrote:
I've tried returning 0,1,2,None. It behaves the same regardless. There is only one user in my development database:

DEBUG:web2py.app.myapp:Found user: 123456789

DEBUG:web2py.app.myapp:    Updated.

DEBUG:web2py.app.myapp:    new task report: COMPLETED

DEBUG:web2py.app.myapp:   result: 1

DEBUG:web2py.app.myapp:Found user: 123456789



The next check is the entries in the "scheduler_run" table, which indicate what the Scheduler thinks happened.

/dps

 

James Holstead

unread,
Apr 26, 2017, 4:07:27 PM4/26/17
to web2py-users
Status is COMPLETED in the scheduler_run table, run time of about 5 seconds. Checking the scheduler_task table I'm noticing the next_run_time is 1 day ahead. period is 86400, repeats is 0, times_run is 1

Thanks for the help!

Anthony

unread,
Apr 26, 2017, 4:21:39 PM4/26/17
to web2py-users
Do you have more than one of the same task getting scheduled? Where is this line:


myScheduler.queue_task('myfunc', repeats=0, period=86400, timeout=1200, prevent_drift=True, immediate=True)

If it is in a model file, every time the model file is accessed (including whenever a scheduler task is run), a new version of the task will be scheduled and run immediately. Is that what is happening?

Anthony
Reply all
Reply to author
Forward
0 new messages