0

What is the best way to implement getting result in short running celery task (3-7 seconds) ?

For now i use this method below.

  • User clicks button which send request to api - api triggers celery task and returns task_id
  • Then we are checking result of task_id via Ajax

UPDATE: question should be closed at it has no difference between getting result from long running task .

Artem Bernatskyi
  • 2,069
  • 1
  • 19
  • 26

1 Answers1

1

As a general rule (with all background tasks, not just Celery/Django) that's actually your best bet. The same pattern emerges

  • User makes HTTP request
  • Server kicks off background service (either through Celergy, some other async. service, or even through a command line execution (<- don't do that if you can avoid it)) and returns some form of identifier
  • User agent makes new HTTP request to get information about state of new service/process.

You should check out long polling

Community
  • 1
  • 1
cwallenpoole
  • 72,280
  • 22
  • 119
  • 159