On Tue, Mar 20, 2012 at 2:52 PM, Arruda <felipe.arruda.pon...@gmail.com> wrote:
> Thanks every one, I've manage to work this around.
> The solution might not be the best, but it's working:
> In the view I call the do_something_slow() in a new thread, and in the end
> of it(after the role process is done) it change the model of a class to add
> the feedback.
> While the thread is running it renders the template to the user(with a
> "Loading..." message).
> Then I've made a ajax_get_feed_back() view to get this feedback.
>
> In the template, I made a simple JS that every second tries to get the
> feedback via ajax.
> And if it gets the feedback it stops requesting it.
> =)
>
> But I still wanted to know how to use the celery in this case =/
> But got very lost in that, does any one have a example(code) of something
> similar to do with it?
> In the docs I only found examples of process that are kind of tasks... to
> run every hour, or things like that.
>

I don't have any easily shareable code, but the basic principle is like this:

Django request comes in
View wants to handle some code in the background
View creates task object, with an id
View renders page, includes task id
Rendered page polls the web server with the id, waiting for the task to finish
Webserver returns data associated with id when task is complete
Javascript inserts data into the page

Meanwhile..

When the task is created, a message is sent to the message broker.
There are several backend task processors attached to the message
broker, and the message is delivered to one of them.
The task processor runs the delayed task, and once complete returns the data.

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to