Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from threading import Thread
- def async(f):
- def wrapper(*args, **kwargs):
- thr = Thread(target = f, args = args, kwargs = kwargs)
- thr.start()
- return wrapper
- @async
- def send_async_email(msg):
- mail.send(msg)
- print('Email send')
- def send_email(subject, sender, recipients, text_body, html_body):
- msg = Message(subject, sender = sender, recipients = recipients)
- msg.body = text_body
- msg.html = html_body
- send_async_email(msg)
Add Comment
Please, Sign In to add comment