On Tuesday, June 11, 2019 at 8:20:13 AM UTC-7, Dave S wrote:
>
>
>
> On Monday, June 10, 2019 at 9:52:59 PM UTC-7, mostwanted wrote:
>>
>> I am yet to understand how the scheduler works.
>>
>> Thanks Dave
>>
>>
> It's simple:  the Scheduler runs as an independent process that watches 
> only one thing:  the list of queued tasks.  When it finds that it is time 
> to run a queued task, it unqueues it and launches it.  A queued task could 
> be one that looks through another table (such as the one used by the web 
> requests), and compares the time of the entries with the current time and 
> decides which ones are stale, and then marks them inactive or deletes them.
>
> Let's say you have a table where users post discussion topics:  perhaps 
> design documents.  The form shown in the browser might include a link to 
> the document, the author's name, the project it applies to, and the date 
> posted.  You also have a field (hidden in the form) for a status of 
> active/inactive/removed.  The removed status is for when the author cancels 
> a document, so we won't worry about that during cleanup.
>
> You want to have the table checked every day at 11:59 pm, and all the 
> active documents older than 2 weeks to be marked inactive.  You set up the 
> Scheduler in your model file, and define a task; that is, you write a 
> function to implement the task (more below).  You start the Scheduler from 
> a command line (bash shell, or on Windows a cmd window). 
>

Using the -K option. 

Or you start the scheduler as a service, basically having systemctld or 
nssm or such run a command line with the -K option.

 

> You also write a small function in one of your controllers that has the 
> scheduler.queue_task() call setting the start time and unlimited repeats 
> and how often it repeats (every 24*60*60 seconds in this case).  You invoke 
> that function (from a browser if you want it to be a web request, from a 
> command line using -S if you want it to be only done from the server 
> environment.
>
> The function you wrote to implement the task is very simple:  select all 
> the documents that are active and are 2 weeks old (post_date.< now() - 
> datetime.delta(2 weeks)) and update the status to inactive.
>
> Also note that recent versions of the scheduler allow you to do a 
> recurring task with a string that looks like a traditional unix/linux cron 
> entry, rather than calculating the number of seconds between runs.
>
>
/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/4facb3ba-6e62-4859-bbf6-a6521fa9211a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to