Implementing a 'please wait' page

39 views
Skip to first unread message

Mohammed Noor

unread,
May 31, 2018, 7:33:50 PM5/31/18
to django...@googlegroups.com
Hello Guys,

I currently have a process running on my django application which takes about 10-15 minutes to complete.

Currently, the user clicks on a 'submit' button and this process starts. The web page remains in a hung state for the complete time this process takes to run and after say 10-15 mins another 'results' page is displayed.


I want to be able to display a page saying 'please wait for <lenght of time taken to complete process>' after submit button is clicked. Can you please give me any ideas on how to implement this.


Here is a rough representation of my code flow:

Main function ():
-lots of code
-call to sub function() //this is the guy taking 10-15 mins to execute
-if sub function() returns true then proceed else break and exit.
-remaining code of Main function()

As you might have guessed, I want to be able to change the display when this sub function () is hit. Btw, main function () is executed when user clicks on submit button.


Appreciate your help!

Thanks and Have a great day,
Mohammed Noor

Mark Phillips

unread,
Jun 1, 2018, 2:26:27 AM6/1/18
to django users
Have you looked at celery (http://www.celeryproject.org/) to handle the long running process? Perhaps in conjunction with redis (https://redis.io/)?

If you passed the long running process to celery, then you could change the page to "say please wait....".

Mark


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5CF991C0-FB63-47BA-9A2A-47224E468D0B%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Mohammed Noor

unread,
Jun 1, 2018, 6:58:40 AM6/1/18
to django...@googlegroups.com
Thanks Mark! I will surely have a look at them. 

But I was hoping if there was a way of getting this done using ajax or jquery.

Mohammed Noor

Jason

unread,
Jun 1, 2018, 7:03:58 AM6/1/18
to Django users
you can with celery, just make a view that checks the task ID of the task and if its PENDING, return 'waiting', which would be used by your browser.

also consider the fact that servers will require you to specifically override the connection timeout setting.  with finite numbers of connections the server has, imagine if 100 users hit your server for tasks and have to wait 15 minutes.  your original method won't scale at all beyond a handful of users.

Mohammed Noor

unread,
Jun 1, 2018, 7:51:57 AM6/1/18
to django...@googlegroups.com
Wow. Yeah. That scenario of 100 users hitting together...honestly, I haven't thought much about it. Would using celery help me overcome this problem? 

On 01-Jun-2018, at 4:33 PM, Jason <jjohn...@gmail.com> wrote:

you can with celery, just make a view that checks the task ID of the task and if its PENDING, return 'waiting', which would be used by your browser.

also consider the fact that servers will require you to specifically override the connection timeout setting.  with finite numbers of connections the server has, imagine if 100 users hit your server for tasks and have to wait 15 minutes.  your original method won't scale at all beyond a handful of users.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

Larry Martell

unread,
Jun 1, 2018, 9:16:22 AM6/1/18
to django...@googlegroups.com
On Thu, May 31, 2018 at 7:35 PM, Mohammed Noor <snm...@gmail.com> wrote:
> Hello Guys,
>
> I currently have a process running on my django application which takes about 10-15 minutes to complete.
>
> Currently, the user clicks on a 'submit' button and this process starts. The web page remains in a hung state for the complete time this process takes to run and after say 10-15 mins another 'results' page is displayed.
>
>
> I want to be able to display a page saying 'please wait for <lenght of time taken to complete process>' after submit button is clicked. Can you please give me any ideas on how to implement this.

The way I have dealt wth this is to define something in the template like this:

<span class='loadMsg' style='display: none; color:lightgray;
text-align: left;'> ... loading images </span>
$('.loadMsg').show();

And then in window.onload function:

$('.loadMsg').hide();

Melvyn Sopacua

unread,
Jun 1, 2018, 10:40:37 AM6/1/18
to django...@googlegroups.com
On vrijdag 1 juni 2018 01:35:36 CEST Mohammed Noor wrote:

> I want to be able to display a page saying 'please wait for <lenght of time
> taken to complete process>' after submit button is clicked. Can you please
> give me any ideas on how to implement this.

As said by others, celery is one way to do this and this tutorial shows all
things required to provide user feedback:

https://buildwithdjango.com/blog/post/celery-progress-bars/

--
Melvyn Sopacua
Reply all
Reply to author
Forward
0 new messages