diff --git a/demoapp/settings.py b/demoapp/settings.py index cab758b..b0cf370 100644 --- a/demoapp/settings.py +++ b/demoapp/settings.py @@ -206,7 +206,7 @@ 'TEMPLATE_ENGINE': 'sendmail', 'CELERY_ENABLED': True, 'MAX_RETRIES': 0, - 'BATCH_SIZE': 200, + 'BATCH_SIZE': 100, 'BATCH_DELIVERY_TIMEOUT': 30, 'MESSAGE_ID_ENABLED': True, 'DEFAULT_PRIORITY': 'medium', diff --git a/sendmail/tasks.py b/sendmail/tasks.py index 6497552..f70e704 100644 --- a/sendmail/tasks.py +++ b/sendmail/tasks.py @@ -35,10 +35,10 @@ def send_queued_mail(*args, **kwargs): To be called by the Celery task manager. """ while True: - if not get_queued().exists(): - break queued_emails = get_queued().select_for_update(of=('self',), skip_locked=True) with transaction.atomic(): + if not queued_emails: + break try: _send_bulk(queued_emails, uses_multiprocessing=False) except Exception as e: