Skip to content

Instantly share code, notes, and snippets.

@Quard
Last active April 12, 2019 13:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Quard/a8fc28a8ec4c27b281acbed25fb90fe9 to your computer and use it in GitHub Desktop.
Save Quard/a8fc28a8ec4c27b281acbed25fb90fe9 to your computer and use it in GitHub Desktop.
The Python Celery Cookbook: Small Tool, Big Possibilities
@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