-
To do any network call in a request-response cycle
Sending the email is a network call and might take 2-3 seconds. User should not be made to wait for these 2-3 seconds. So sending activation email should be done outside of request-response cycle. It can be achieved using celery.
-
Breaking a large task consisting of several independent parts into smaller tasks
If you write a single function to sequentially hit 5 endpoints provided by FB and if network calls take 2 seconds at an average, then your function will take 10 seconds to complete. So you can split your work in 5 individual tasks(it’s very easy to do as we will soon see), and let Celery handle the tasks. Celery can hit these 5 endpoints parallely and you can get the response from all the endpoints within first 2 seconds.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Month | wikidatacomplete-backend | Wikidata-Complete-Gadget | |
---|---|---|---|
June | 2 | 2 | |
July | 17 | 1 | |
August | 9 | 1 | |
September | 2 | 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In [1]: from pdfs.models import Question, Choice | |
In [2]: Question.objects.count() | |
Out[2]: 0 | |
In [3]: Choice.objects.count() | |
Out[3]: 0 | |
In [4]: q = Question( | |
...: question_text="who is best football player?" |