Friday, March 30, 2018

Re: How to make asynchronous ajax requests if the server side work takes plenty of time to finish?

I think a typical approach would be, using Django celery to process your heavy workload in the background, and then when finished, notify the user via email, text, or maybe have a periodic async ajax call check to see if there are completed tasks not yet looked at

On Fri, Mar 30, 2018 at 12:53 AM, Chasan KIOUTSOUKMOUSTAFA <chasank@gmail.com> wrote:

I need advice or sample code to achieve a task related asynchronous ajax request that server side work takes plenty of time to finish its job.


Here is the sample scenario;

I've a simple CSV file upload form. User submits file

  • Server starts processing CSV file.
  • Server makes queries to external REST apis for each line of CSV file. (additional network request/response delays)
  • Server parses each response (regex calculations, additional delays) and stores data into database.
  • Server produces another output CSV file.

If the CSV file contains < 100 rows, it works even without using ajax. However I need to make it asynchronous to be able to feed a lot of rows. The critical part is I don't want to have timeouts as long as server side code is working. I want to be able to update client side regularly about the progress of work (log-like update, for example "x record is saved into database")

Can you provide me a working dummy sample code (for example, calculating fibonacci numbers) both client side and server side. (if possible django)

Thanks.

Regards.

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3d3a12f6-98dd-4084-a9e6-322b3b04332a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAAuoY6POU2dmNg8psGtFWCS2ehXx9xtuhuta32-KCa7v3h%3Du%2Bg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment