Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from threading import Thread
- def send_async_email(msg):
- sleep(10)
- print('Sending message')
- mail.send(msg)
- 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
- thr = Thread(target = send_async_email, args = [msg])
- thr.start()
- async def send_async_mail(app, msg):
- with app.app_context():
- mail.send(msg)
- def send_mail(subject, sender, recipients, text_body, html_body):
- msg = Message(subject, sender=sender, recipients=recipients)
- msg.body = text_body
- msg.html = html_body
- mail.send(msg)
- send_async_mail(app, msg)
- RuntimeWarning: coroutine 'send_async_mail' was never awaited send_async_mail(app, msg)
- RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement