Thanks for the update. Hopefully I won't need it 😏 On Tue, 30 Jun 2020, 2:12 am Pierre, <pcg...@gmail.com> wrote:
> For a temporary solution, i made an external python prg and used cron on > my pi to sync the databases everynight and works find with sqlite syntax. > It's way more extensive work but seems to be reliable for many days now. > I have read again the doc, and cannot figure out at all my mistake. > At this time i scheduled manualy the task via the admin interface to do > tests, so i can follow the stage, queued, running, etc. > thanks > > Le mercredi 24 juin 2020 23:01:27 UTC-4, Dave S a écrit : >> >> >> >> On Wednesday, June 17, 2020 at 6:41:32 AM UTC-7, Pierre wrote: >>> >>> Gooday, >>> In the controler the function works correctly. But as a task, it gives >>> an error about Json not beeing able to deal with datetime. >>> any suggestion would be appreciated :) >>> >>> here is the error : TypeError: datetime.datetime(2020, 6, 16, 5, 17, >>> 49) is not JSON serializable >>> >>> >> This does not look right: >> >> >>> from gluon.scheduler import Scheduler >>> >>> Scheduler(db,dict(sync_data=pump_most_recent,sync_dates=acue_src_dst_update)) >>> >>> >> In a models file called scheduler.py, I have: >> >> >> from gluon.scheduler import Scheduler >> >> scheduler = Scheduler(db) >> >> >> def taskfunc(arg1, arg2): >> var1 = do_something(arg1) >> if var1 in arg2: >> return "success" >> >> >> In a controller, I kick off the task with >> >> chunk1 = dostuff(request.args[0]) >> string1 = targets[rand()] >> tid = scheduler.queue_task('taskfunc', pvars={'arg1': chunk1, 'arg2': >> string2}, timeout=1200) >> >> (the controller knows scheduler from the models) >> >> Sending a date as an argument would be done by using a pvars dictionary >> in the same way. For one of my tasks, I send a datetime via pvars. The >> task also has a request.now. (It has the whole request, but you can tell >> it's a scheduler request). >> >> Do you find the documentation on Scheduler unclear? >> >> /dps >> >> >> >> -- > 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+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/web2py/38baa4e9-9942-4faf-bc57-4e12d59051beo%40googlegroups.com > <https://groups.google.com/d/msgid/web2py/38baa4e9-9942-4faf-bc57-4e12d59051beo%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/CACWMBMPgx2dQ1tGYaqNyE29QDXrAgnPY9nHzuaJSJ2SFQsmxnQ%40mail.gmail.com.