javascript - Django: how to poll a django application for updates on an asynchronous task? (noob edition) -


note: noob edition i.e. requires thoroughly explained answer myself , others can use reference.

a demo project available on gitlab , github


context

i have simple application in django consists of form , results page. after form submitted there processing can take quite time.

naturally, nice to:

  1. run computation asynchronously user results page faster
  2. provide updates user of progress of request.

so have tried figuring out how , hasn't gone well.

to understanding should following:

  • install celery
  • make app in celery task computation
  • have task output progress either log file or update model (if model has status field)
  • use js , jquery or angular.js or node.js , socket.io somehow poll application progress.

and there whatever else told or can find either glosses on how works, assumes know how works , can adapt use case, or if try explain it.

i not understand answers (so referencing them doesn't any)

question

how can status updates asynchronous task run in django application?

how answer

since other posts have not been enough me understand how (and given number of other posts related this, not alone), made demo project (gitlab, github) in django has setup referring (a page form , page show status of results until results ready). looking explain via this demo project how poll server status of asynchronous task (and generous comments).

don't want use celery? want use redis instead of rabbitmq? use of node.js , socket.io? fine , fair game. comment changes made , make clear how additions make possible run asynchronous task , query status.

about demo project

in demo project have 2 views index , query. index has simple form 2 integers. when form submitted, redirect query view.

there file called tasks.py has simple task adding 2 integers provided in form.

how modify simple demo project such can asynchronously run task , query view realtime updates status of computation.

since computation here simple, pause statements might necessary or task might have changed (e.g. recursively add 2 number 10000 times)

thank understanding , in teaching how important feature.


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -