Created
January 11, 2022 11:10
-
-
Save sirrobot01/ed85a66defc30d9c0b2207ebfdd4932a to your computer and use it in GitHub Desktop.
Async email sender using Django
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
@app.task | |
def send_email(*args, **kwargs): | |
time.sleep(1000000) | |
return send_mail(*args, **kwargs) | |
class SendEmail: | |
def __call__(self, *args, **kwargs): | |
return self.run(*args, **kwargs) | |
def run(self, *args, **kwargs): | |
return send_email.delay(*args, **kwargs) | |
async_send_email = SendEmail() | |
### Running | |
async_send_email('Subject here', 'Here is the message.', 'from@example.com', ['to@example.com'], fail_silently=False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment