I've figured it out: when using a central db for the scheduler, there is no
need (at least in this case) of calling web2py.py -K with all the apps,
just with the main app, in my case:
python /home/user/web2py/web2py.py -K masterapp
Sorry I bothered you. Maybe someday someone is having the same problem as
me, and ends up here with the solution :)
El lunes, 11 de mayo de 2015, 21:15:03 (UTC-3), Lisandro escribió:
>
> I have *one master app* that handles the *main db, in which the scheduler
> tables have been created*.
>
> This master app has a scheduler.py module that looks like this (for now,
> with no function tasks defined):
>
> # -*- coding: utf-8 -*-
> from gluon.scheduler import Scheduler
> scheduler = Scheduler(db, max_empty_runs=5)
>
>
> In the other hand, I have *multiple secondary apps*, each one with it's
> own db.
> All this applications *instantiate the scheduler specifying the central
> db*, like this:
>
> def test():
> print 'this is just a test task'
> return True
>
> from gluon.scheduler import Scheduler
> db_scheduler = DAL('postgres://user:password@host/centraldb',
> lazy_tables=True, migrate=False)
> scheduler = Scheduler(db_scheduler, max_empty_runs=5)
>
>
> Then, *the tasks are queued from the master app*, like this:
>
> scheduler.queue_task('test', period=60, repeats=0, application_name='app1')
> scheduler.queue_task('test', period=60, repeats=0, application_name='app2')
> scheduler.queue_task('test', period=60, repeats=0, application_name='app3')
>
>
> Then, I start the scheduler like this (from unix cron, every 5 minutes or
> so):
>
> python /home/user/web2py/web2py.py -K app1,app2,app3
>
> I can see the task moves to "RUNNING" state, but *the task stucks running
> until the configured timeout*.
>
> Am I using correctly the "application_name" parameter of the
> "queue_task()" function?
> I assume that the scheduler will pick up the task and check for that
> field, so the task function will be called in the context of the
> corresponding application.
>
> Notice that the scheduler.py model of the master app doesn't have any
> function defined. Instead, taks functions are defined in the scheduler.py
> model of every secondary app. That's why, when I queue a task, I specify
> the application_name... However, at the end, the scheduler shows that the
> task is running (when it's not actually), and then the timeout.
>
> Any help will be really appreciated!
>
--
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.