Created
August 16, 2016 16:30
-
-
Save rfj001/b762bdb2dcf52c3ab315ef3cbbb739e8 to your computer and use it in GitHub Desktop.
Avoid noticeable page-load slowdown when sending emails with django-allauth by sending email in background
This file contains hidden or 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
import threading | |
from allauth.account.adapter import DefaultAccountAdapter | |
class BackgroundEmailSendingAccountAdapter(DefaultAccountAdapter): | |
def send_mail(self, template_prefix, email, context): | |
mailing_thread = threading.Thread( | |
target=super(BackgroundEmailSendingAccountAdapter, self).send_mail, | |
args=(template_prefix, email, context) | |
) | |
mailing_thread.start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment