Changeset - abc146bfdbaa
[Not reviewed]
default
0 1 0
Dennis Fink - 11 years ago 2014-07-16 20:53:37
dennis.fink@c3l.lu
Async send doesn't work
1 file changed with 1 insertions and 16 deletions:
0 comments (0 inline, 0 general)
ennstatus/status/functions.py
Show inline comments
 
@@ -4,7 +4,6 @@ import json
 

	
 
from collections import defaultdict
 
from datetime import datetime
 
from threading import Thread
 

	
 
from flask import current_app
 
from flask_mail import Mail, Message
 
@@ -13,20 +12,6 @@ from flask_mail import Mail, Message
 
mail = Mail()
 

	
 

	
 
def async(f):
 

	
 
    def wrapper(*args, **kwargs):
 
        thr = Thread(target=f, args=args, kwargs=kwargs)
 
        thr.start()
 

	
 
    return wrapper
 

	
 

	
 
@async
 
def send_async_mail(msg):
 
    mail.send(msg)
 

	
 

	
 
def _send_mail(server_name, status, last_updated):
 

	
 
    current_app.logger.info('Try sending mail')
 
@@ -36,7 +21,7 @@ def _send_mail(server_name, status, last
 
        msg.add_recipient(current_app.config['SERVER_ADMINS'][server_name])
 
        msg.body = ('%s went to %s. I received the last update at %s'
 
                    % (server_name, status, last_updated))
 
        send_async_mail(msg)
 
        mail.send(msg)
 
    except KeyError:
 
        current_app.logger.error('Admin for %s not found!' % server_name)
 
    except AssertionError:
0 comments (0 inline, 0 general)