Skip to content

Instantly share code, notes, and snippets.

View lalit97's full-sized avatar

Lalit Suthar lalit97

View GitHub Profile
@lalit97
lalit97 / wikidata-complete-contributions.csv
Last active September 13, 2022 14:52
contributions table for wikidata-complete gsoc
Month wikidatacomplete-backend Wikidata-Complete-Gadget
June 2 2
July 17 1
August 9 1
September 2 0

When to use Celery

  1. 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.

  2. 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.

@lalit97
lalit97 / serializers.py
Created July 3, 2021 13:26
ajay-discussion
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?"