Last active
April 12, 2019 13:09
-
-
Save Quard/a8fc28a8ec4c27b281acbed25fb90fe9 to your computer and use it in GitHub Desktop.
The Python Celery Cookbook: Small Tool, Big Possibilities
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
@celery_app.task | |
def send_good_morning_mail_task(offset=0, limit=100): | |
users = User.objects.filter(is_active=True).order_by('id')[offset:offset + limit] | |
for user in users: | |
send_good_morning_mail(user) | |
if len(users) >= limit: | |
send_good_morning_mail_task.delay(offset + limit, limit) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment