Issue
I'm using Django to upload a file and kick of an ETL job using
subprocess
The job takes roughly 15 seconds to run, and rather than having the user think the page is frozen, I'd like to show a progress bar.
I can figure out the AJAX to update the progress bar, but what I don't know how to do is return an HttpResponse while subprocess is running. Perhaps threading is the solution? I don't have any experience there. Can someone give me some guidance?
Here's the view:
def start_job(request):
if request.method == 'POST':
form = UploadForm(request.POST, request.FILES)
if form.is_valid() and form.is_multipart():
save_file(form.cleaned_data['file'])
subprocess.call(["Kitchen.bat", "/file:job.kjb"])
return HttpResponseRedirect('/success/')
else:
form = UploadForm()
return render_to_response('template.html')
Solution
Thanks @Bula, django-celery is the perfect solution.
Here's a good introductory video to get started.
Answered By - jdickson
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.