Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Celery task fails with 'too many concurrent connections' #85

Open
erichhasl opened this issue Jan 13, 2022 · 0 comments
Open

Celery task fails with 'too many concurrent connections' #85

erichhasl opened this issue Jan 13, 2022 · 0 comments

Comments

@erichhasl
Copy link

When sending a lot of mails with django-celery-email as backend, I often get an error in my celery logs, that there were too many concurrent connections.

I have set EMAIL_BACKEND accordingly:

EMAIL_BACKEND = 'djcelery_email.backends.CeleryEmailBackend'

And I am sending emails like so:

with mail.get_connection() as connection:
    for recipient in set(recipients):
        email = EmailMessage(subject, content, sender, [recipient],
                             headers=headers,
                             connection=connection, **kwargs)
        if attachments is not None:
            for attach in attachments:
                email.attach_file(attach)
        try:
            email.send(fail_silently=True)
        except Exception as e:
            print("Error when sending mail:", e)
            failed = True
        else:
            succeeded = True

I was expecting that this opens one connection and sends all emails using this one connection. Is this a wrong assumption? How can I force the mail backend to only use one single connection?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant