On Sunday, July 5, 2015 at 11:15:56 AM UTC-4, Aydin S wrote:
>
> I'm trying to run two different function with two different periodic 
> times. I think what you mean is that I still can do it using 
> from gluon.scheduler import Scheduler
> Scheduler(db,dict(function1=f1,function2=f2))
>
> and then in the schedule use function1 and function2 to create two 
> different periodic tasks. I've tried this, and it did not work. 
>

Please read the Scheduler documentation: 
http://web2py.com/books/default/chapter/29/04/the-core#web2py-Scheduler.

Your second line should be something like:

scheduler = Scheduler(db, ...)

otherwise, you will have no way to refer to the Scheduler object later in 
your code when you want to schedule a task.

Just make sure function1 and function2 have been defined (or imported from 
a module) before the above lines. If for some reason you need to define one 
of the functions later, note that the second argument to Scheduler() is 
optional (i.e., you don't have to provide a dictionary mapping task names 
to functions -- you can instead pass a function directly to 
scheduler.queue_task when you actually queue a task). I think you can also 
update the task dictionary at a later point:

scheduler.tasks.update('new_task'=new_function)

Anthony

-- 
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.

Reply via email to