quoting myself

ation of the Scheduler *AND the definition of tasks*
....
itions *should be available on models* .... so they'd be available to the 
app and will be executed without issues

So. 
- One scheduler per app: ok!
- tasks definition on scheduler instantiation: as long as the task function 
exist when the scheduler is istantiated (ko!, it seems in your case)

I'd go for:
- one scheduler per app
- tasks definition on models
*- tasks queuing within the plugin *

The part in bold works really fine because of some magic: as long as you 
queue tasks within the plugin's controller code, the task gets queued with 
function_name=your_function_name AND - automagically - application_name = 
app_name/plugin_controller_name , which in turns ensures that every model 
defined for that plugin is executed BEFORE calling the function itself. 
This means that you'd be sure that at the time the function gets called, 
it's already defined (because model's execution comes first, and 
"populates" the environment with the task definition)
That being said, nothing is stopping you from side-stepping magic (as 
always in web2py): you can queue your function (defined, e.g. in a "plugin" 
model) explicitely passing application_name as 
"app_name/plugin_controller_name". You make your own magic. 
 

On Thursday, December 17, 2015 at 8:42:31 PM UTC+1, mi...@thesmartcone.com 
wrote:
>
> Ok If I understand you correctly,
>
> I should only instantiate one Scheduler in the App and the Tasks should be 
> defined in the models of the plugins. ( I was instantiating a Scheduler() 
> in each plugin) 
>
> If I define taskA() in a model called plugin_A.py and taskB() in a model 
> plugin_B.py then I try to instantiate the scheduler in the App using :
>
> from gluon.scheduler import Scheduler
> Scheduler(db,dict(A=taskA,B=taskB))
>
> I get an error in the App Model 'TaskA is not defined'
>
> Thanks for your help.
>
> On Wednesday, December 16, 2015 at 3:00:15 PM UTC-5, Niphlod wrote:
>>
>> This is definitely weird. 
>> Unless you're plugins that carry themselves the instantiation of the 
>> Scheduler AND the definition of tasks: there should be only ONE scheduler 
>> instance (because it's thought as a singleton) and tasks definitions should 
>> be available on models .... so they'd be available to the app and will be 
>> executed without issues.
>>
>> On Wednesday, December 16, 2015 at 11:33:51 AM UTC+1, 
>> mi...@thesmartcone.com wrote:
>>>
>>> I have 2 different plugins that currently use Web2Py Scheduler. They 
>>> both work when they are installed in an App separately. If they are both 
>>> isnstalled in the same App only one of the plugins scheduled tasks get run. 
>>> (The one with the last loaded model alphabetically). Can someone point me 
>>> in the right direction to get this working?
>>>
>>> Thanks,
>>>
>>> Mike
>>>
>>

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to