"""What I am not clear on is the best way to invoke this code so that only 
one copy of the task is created"""

if you need what you asked, that is the way to do it. You asked for a piece 
of code that ensures a task is queued but only that one.
My solution to the "problem" is having a piece of code that does that, but 
it doesn't do at each and every request.

if you put anywhere in a controller something like

def this_queues_the_task(a=None):
      .... code that checks if it's already there and in case it queues it 
(or it alerts you, or whatever)

you will be sure that nobody can use it when hitting , e.g., 
/app/controller/this_queues_the_task because it is "protected" by an 
argument (web2py exposes only functions without args or kwargs).... but you 
can call it from the shell

web2py.py -M -S app/controller/this_queues_the_task

without issues. You can then use that call whenever you want, from wherever 
you want, and live happily knowing that your task is there.


Summing up, the real deal is that there's no way to monitor something you 
don't trust without having something that monitors it that you trust.
Choose whatever tool (or person) and method (or procedure) you like, but 
there's really no way around it.

On Monday, August 22, 2016 at 2:13:03 PM UTC+2, Scott Hunter wrote:
>
> What is a "protected controller"?  It sounds like I need a recurring task 
> to monitor my recurring task ("recurring tasks all the way down").
>
> - Scott
>
> On Monday, August 22, 2016 at 7:47:07 AM UTC-4, Niphlod wrote:
>>
>> just queue the task in a protected controller that checks before 
>> inserting if another instance has been already queued.... and call that 
>> protected controller once in a while (i.e. once per day)
>>
>> On Monday, August 22, 2016 at 3:10:44 AM UTC+2, Scott Hunter wrote:
>>>
>>> The book seems pretty clear about the call to use to start a recurring 
>>> task.  
>>>
>>> What I am not clear on is the best way to invoke this code so that only 
>>> one copy of the task is created (assuming the scheduler machinery will 
>>> handle making sure that it keeps recurring).
>>>
>>> - Scott
>>>
>>

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