you need to call db.commit() in your task: this is both on the book and probably on the 90% of the threads regarding the scheduler :-P
On Saturday, May 28, 2016 at 12:53:53 PM UTC+2, Mohit Jain wrote: > > I am stuck with a similar situation here. > > I have the models/scheduler.py > from gluon.scheduler import Scheduler > > def auto_insert(): > try: > db.UserLogs.insert(user_name='temp',user_email='[email protected] > <javascript:>',activity='checking scheduler') > return 'inserted' > except: > return 'failed' > > scheduler = Scheduler(db, dict(auto_insert=auto_insert)) > > > And I run the scheduler tasks as > [taship@taship web2py]$ python web2py.py -K taportaltest > web2py Web Framework > Created by Massimo Di Pierro, Copyright 2007-2016 > Version 2.9.11-stable+timestamp.2014.09.15.23.35.11 > Database drivers available: SQLite(sqlite3), MySQL(pymysql), > PostgreSQL(pg8000), MSSQL(pyodbc), DB2(pyodbc), Teradata(pyodbc), > Ingres(pyodbc), IMAP(imaplib) > starting single-scheduler for "taportaltest"... > > Then I use the appadmin to start the background tasks. > Application Name: > Task Name: > Group Name: > Status: QUEUEDRUNNINGCOMPLETEDFAILEDTIMEOUTSTOPPEDEXPIRED > Function Name: auto_insert > Uuid: > Args: > Vars: > Enabled: > Start Time: > Next Run Time: > Stop Time: > Repeats: 0=unlimited > Retry Failed: -1=unlimited > Period: seconds > Prevent Drift: Cron-like start_times between runs > Timeout: seconds > Sync Output: update output every n sec: 0=never > Times Run: > Times Failed: > Last Run Time: > Assigned Worker Name: > > and things seem to be fine... > > > scheduler_run.id > <http://localhost:8001/taportaltest/appadmin/select/db?orderby=scheduler_run.id> > scheduler_run.task_id > <http://localhost:8001/taportaltest/appadmin/select/db?orderby=scheduler_run.task_id> > scheduler_run.status > <http://localhost:8001/taportaltest/appadmin/select/db?orderby=scheduler_run.status> > scheduler_run.start_time > <http://localhost:8001/taportaltest/appadmin/select/db?orderby=scheduler_run.start_time> > scheduler_run.stop_time > <http://localhost:8001/taportaltest/appadmin/select/db?orderby=scheduler_run.stop_time> > scheduler_run.run_output > <http://localhost:8001/taportaltest/appadmin/select/db?orderby=scheduler_run.run_output> > scheduler_run.run_result > <http://localhost:8001/taportaltest/appadmin/select/db?orderby=scheduler_run.run_result> > scheduler_run.traceback > <http://localhost:8001/taportaltest/appadmin/select/db?orderby=scheduler_run.traceback> > scheduler_run.worker_name > <http://localhost:8001/taportaltest/appadmin/select/db?orderby=scheduler_run.worker_name> > 6 <http://localhost:8001/taportaltest/appadmin/update/db/scheduler_run/6> > auto-insert > <http://localhost:8001/taportaltest/appadmin/update/db/scheduler_task/2> > COMPLETED 2016-05-28 16:18:47 2016-05-28 16:18:47 "inserted" None > taship.iiit.a... > 7 <http://localhost:8001/taportaltest/appadmin/update/db/scheduler_run/7> > auto-insert > <http://localhost:8001/taportaltest/appadmin/update/db/scheduler_task/2> > COMPLETED 2016-05-28 16:19:06 2016-05-28 16:19:07 "inserted" None > taship.iiit.a... > 8 <http://localhost:8001/taportaltest/appadmin/update/db/scheduler_run/8> > auto-insert > <http://localhost:8001/taportaltest/appadmin/update/db/scheduler_task/2> > COMPLETED 2016-05-28 16:19:22 2016-05-28 16:19:22 "inserted" None > taship.iiit.a... > 9 <http://localhost:8001/taportaltest/appadmin/update/db/scheduler_run/9> > auto-insert > <http://localhost:8001/taportaltest/appadmin/update/db/scheduler_task/2> > COMPLETED 2016-05-28 16:19:38 2016-05-28 16:19:40 "inserted" None > taship.iiit.a... > 10 > <http://localhost:8001/taportaltest/appadmin/update/db/scheduler_run/10> > auto-insert > <http://localhost:8001/taportaltest/appadmin/update/db/scheduler_task/2> > COMPLETED 2016-05-28 16:19:55 2016-05-28 16:19:56 "inserted" None > > But the database (db.UserLogs) is not being updated :/ > > What am I missing here? Do I need to specifically import the database > classes into scheduler.py? > > Regards, > Mohit > > On Thursday, February 25, 2016 at 1:41:04 PM UTC+5:30, Niphlod wrote: >> >> if anyone wants to familiarize with the scheduler, I always recommend >> https://github.com/niphlod/w2p_scheduler_tests >> <https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2Fniphlod%2Fw2p_scheduler_tests&sa=D&sntz=1&usg=AFQjCNEmvCBDd7yA9iLv9ZtUdQkrJ5QMvQ> >> > -- 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 [email protected]. For more options, visit https://groups.google.com/d/optout.

