This library makes it easy to display progress to users on long-running tasks. It can be used directly with existing Celery tasks. Here's a quick demo:
# mymodule/views.py
from celery import task
from hivelocity.asyncweb import async_group
@task
def my_task(a, b, c):
do_something_longrunning(a, b, c)
def my_view(request):
group = async_group(1, 2, 3, user=request.user)
for i in xrange(10):
group.add_call(i, i*10, i*100)
return render(request, 'my-template.html', {'task_id': group()})<!-- my-template.html -->
<h1><span id="progress-text">Nothing</span> done</h1>
<div style="width: 500px; height: 30px; outline: 1px solid black;">
<div id="progress" style="width: 0; height: 100%; background: blue;"></div>
</div>
<script>
var task = new AsyncTask('{{ task_id|escapejs }}', {
'reload_on_complete': true,
'progress_text': '#progress-text',
'progress_bar': '#progress'
});
</script>This results in a page like this:
