Loader/waiting indeterminate progressbar

70 views
Skip to first unread message

Jitun John

unread,
Jun 16, 2016, 11:52:34 AM6/16/16
to web2py-users
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.

Between the 2 pages, I am trying to see if there can be a indication on the HTML page indicating working in background.

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.

Dave S

unread,
Jun 16, 2016, 4:20:17 PM6/16/16
to web2py-users


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.

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

 

Jitun John

unread,
Jul 6, 2020, 10:40:37 AM7/6/20
to web2py-users
4 years and I have not been able to get to this.
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.

Dave S

unread,
Jul 9, 2020, 5:41:19 PM7/9/20
to web2py-users


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.
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
Reply all
Reply to author
Forward
0 new messages