Created
November 22, 2011 08:52
-
-
Save mjallday/1385225 to your computer and use it in GitHub Desktop.
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
for transaction in NewsletterTransaction.objects.filter(sent=None): | |
... | |
# to | |
while NewsletterTransaction.objects.filter(sent=None).count(): | |
for transaction in NewletterTransaction.objects.filter(sent=None).limit(10): | |
... | |
# taking 10 at a time and then doing a new query. this way you're | |
# going to know if someone else is updating the db from anther place | |
# and can use this as a kill switch e.g. run into the db and set | |
# to some value will stop the process from completing the rest of the | |
# email send without having to kill the server process. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment