Skip to content

Instantly share code, notes, and snippets.

@sirrobot01
Created January 11, 2022 11:10
Show Gist options
  • Save sirrobot01/ed85a66defc30d9c0b2207ebfdd4932a to your computer and use it in GitHub Desktop.
Save sirrobot01/ed85a66defc30d9c0b2207ebfdd4932a to your computer and use it in GitHub Desktop.
Async email sender using Django
@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