celery_tasks.py
Python script, ASCII text executable
1import time 2from celery import shared_task 3from app import db 4from models import * 5from smtplib import SMTP 6import config 7 8 9@shared_task(ignore_result=False) 10def send_notification(notification_id, users, level): 11notification = db.session.get(Notification, notification_id) 12 13for user in users: 14db.session.add(UserNotification(db.session.get(User, user), notification, level)) 15db.session.commit() 16 17return 0 # notification sent successfully 18