On Monday, July 6, 2020 at 7:40:37 AM UTC-7, Jitun John wrote:
>
> 4 years and I have not been able to get to this.
> I checked https://groups.google.com/forum/#!topic/web2py/zgSLxeg7avw
> and tried to see if that works with the latest build of web2py.. but it 
> does not.
> I am no developer .. but rely on looking at examples and modify to my 
> needs. kind of hobbyist. Tried reading the scheduler.. but an example would 
> have helped get my head around it. 
>
> It would be kind of someone to provide an example (if it is handy)
>
> Thanks a lot.
>
>
I have nothing handier than the links in the earlier message.

I did not find it hard to use the scheduler, myself, and the examples in 
the book are pretty easy (I think so, anyway).  I use the  scheduler both 
for regular occurring tasks and for tasks that run in response to a 
request.  In the latter case, the task is queued from the controller code 
handling the user's request, and the parameters are set to run once.  For 
the former, there's some information in the deployment chapter about how to 
initialize the scheduler if you have console access, and I believe that can 
be adapted for use in the system startup files.

To use the scheduler, you need 
* a model file that instantiates the Scheduler and provides a function for 
the Scheduler to call
* a controller or local procedure to queue the task
* a controller to access the results if they need to be returned to the user

Optionally, 
* a module to provide more complex code that the model file function can 
call.

(My tasks tend to store stuff in the database and/or send emails, so it's 
queue-and-forget for me.)

/dps


On Friday, June 17, 2016 at 1:50:17 AM UTC+5:30, Dave S wrote:
>>
>>
>>
>> On Thursday, June 16, 2016 at 8:52:34 AM UTC-7, Jitun John wrote:
>>>
>>> From the main page, once a form is submitted, there is heavy python code 
>>> doing lots of steps which takes from seconds to minutes to finish.
>>> It then moves to the next page.
>>>
>>
>>
>> This sounds like something that should be done with the scheduler.  Your 
>> server (apache, nginx) may timeout the request if you try to handle that 
>> big a job in line.
>>  
>>
>>>
>>> Between the 2 pages, I am trying to see if there can be a indication on 
>>> the HTML page indicating working in background.
>>> Something similar to http://www.w3schools.com/howto/howto_css_loader.asp
>>>
>>> I tried to show responce.flash, tried to create an intermediary page 
>>> with the loader code above, but nothing works.
>>> Once the python code starts to work, html page can only be seen once it 
>>> is done.
>>>
>>> response.flash = DIV('All Good...', BR(), 'Working hard to Parse the 
>>> Logs... Please Wait...', BR(), 'Check the Console Window for Progress...')
>>>
>>> create_all_sqlite_tables(uniq_log_path) ------> time consuming code
>>> create_mg_db(uniq_log_path)             ------> time consuming code
>>> redirect(URL('management_summary', args=form.vars.id))
>>>
>>>
>>>
>>> before the time consuming code kicks in ... we have flash.. but it doest 
>>> show up..
>>>
>>> I tried to redirect to a intermediate URL which had the css_loader 
>>> page... and added the heavy code there.. but I never see that page as well.
>>>
>>> All I would want is to put a loader css on probably the main page as 
>>> soon as the form is accepted... if possible.
>>>
>>
>>
>> There have been several discussions of progress bars here recently.  One 
>> such thread is
>> <URL:https://groups.google.com/d/topic/web2py/zgSLxeg7avw/discussion>
>>
>> That thread references using the scheduler, but doesn't show it ... the 
>> solutions show simulating progress by just bumping a session value each 
>> update.  Updates are done using ajax with the browser, so there is some 
>> javascript on the client side.
>>
>> Your scheduler task could update the progress value based on which part 
>> of the computation it is in (or if there's just a big loop chewing on 
>> mouthfuls of data, do an "if loopindex % 50: 
>> update_progress_value(loopindex)".
>>
>> /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/9e0b298a-ccbd-438d-a285-ac43070878dco%40googlegroups.com.

Reply via email to