Django/Web Programming Pattern

36 views
Skip to first unread message

Timothy W. Cook

unread,
Nov 14, 2013, 2:37:17 PM11/14/13
to django...@googlegroups.com
Well, this isn't likely a Django specific question but since this
project is built in Django, I'd like to know how best to handle this
issue.

I have a view that calls a function and performs a long running
process. It reads and processes a file, creating potentially
thousands of objects and can take up to several minutes to complete.

Right now it just displays a pretty much blank template. This isn't
very user friendly. I imagine some kind of counter or progress bar
but I am not certain how best to display this via Django.

What do others do in this case?

Thanks,
Tim



--
MLHIM VIP Signup: http://goo.gl/22B0U
============================================
Timothy Cook, MSc +55 21 94711995
MLHIM http://www.mlhim.org
Like Us on FB: https://www.facebook.com/mlhim2
Circle us on G+: http://goo.gl/44EV5
Google Scholar: http://goo.gl/MMZ1o
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook

Jonathan Baker

unread,
Nov 14, 2013, 2:39:49 PM11/14/13
to django...@googlegroups.com
This sounds like a good candidate for an async Celery task: http://docs.celeryproject.org/en/latest/index.html


--
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2B%3DOU3WXxamXh3avPc%2BmW0yWHJERPACsvvLErx9T8OJc%3D5tsUA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Jonathan D. Baker
Developer
http://jonathandbaker.com

Timothy W. Cook

unread,
Nov 14, 2013, 3:04:15 PM11/14/13
to django...@googlegroups.com
Thanks Jonathan. Looks interesting from the FAQ.
I'll give it a shot and see what happens.
> https://groups.google.com/d/msgid/django-users/CAPMFOb4M7BSndCdN3N0STgwiN%2BA%2BbAZ5f80OkqBtLB1xosfr7A%40mail.gmail.com.
> For more options, visit https://groups.google.com/groups/opt_out.



--

Larry Martell

unread,
Nov 14, 2013, 3:15:26 PM11/14/13
to django...@googlegroups.com
On Thu, Nov 14, 2013 at 9:37 AM, Timothy W. Cook <t...@mlhim.org> wrote:
Well, this isn't likely a Django specific question but since this
project is built in Django, I'd like to know how best to handle this
issue.

I have a view that calls a function and performs a long running
process.  It reads and processes a file, creating potentially
thousands of objects and can take up to several minutes to complete.

Right now it just displays a pretty much blank template.  This isn't
very user friendly.  I imagine some kind of counter or progress bar
but I am not certain how best to display this via Django.

What do others do in this case?

I have a situation where I'm loading a lot of images that takes a long time. What I do is I have this code in my template:

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

$('.loadMsg').show();

window.onload = function() {
    $(function() {
        $('.loadMsg').hide();
    });
};

Not the most elegant thing in the world, but it works and meets my needs. YMMV

Jonathan Baker

unread,
Nov 14, 2013, 3:18:48 PM11/14/13
to django...@googlegroups.com
You're welcome. I just set celery+rabbitmq up on a new project, and while it can seem like a lot of steps (and potential information overload), it isn't so bad once you get a grasp on the concepts.

One thing that recently bit me: once in production with running workers, if the models your task code are interacting with change (in my case, a south migration from concrete inheritance to abstract), you need to restart the workers just like you would Apache (doc: http://docs.celeryproject.org/en/latest/userguide/workers.html#restarting-the-worker). This seems obvious to me know, but hindsight...



Amirouche Boubekki

unread,
Nov 14, 2013, 3:21:20 PM11/14/13
to django...@googlegroups.com
Celery might overkill they are other more simple solutions that only involve your current database and cron jobs.

Regards,


Amirouche


2013/11/14 Jonathan Baker <jonathand...@gmail.com>

Claudio Filho

unread,
Nov 14, 2013, 3:24:59 PM11/14/13
to django...@googlegroups.com

Óhoz

Reply all
Reply to author
Forward
0 new messages