Guest User

Untitled

a guest
Sep 21st, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. from threading import Thread
  2.  
  3. def async(f):
  4. def wrapper(*args, **kwargs):
  5. thr = Thread(target = f, args = args, kwargs = kwargs)
  6. thr.start()
  7. return wrapper
  8.  
  9. @async
  10. def send_async_email(msg):
  11. mail.send(msg)
  12. print('Email send')
  13.  
  14. def send_email(subject, sender, recipients, text_body, html_body):
  15. msg = Message(subject, sender = sender, recipients = recipients)
  16. msg.body = text_body
  17. msg.html = html_body
  18. send_async_email(msg)
Add Comment
Please, Sign In to add comment