handle ObjectDeletedError
This commit is contained in:
parent
24a392818b
commit
922fa4925e
15
cron.py
15
cron.py
|
@ -8,6 +8,7 @@ import arrow
|
||||||
import requests
|
import requests
|
||||||
from sqlalchemy import func, desc, or_
|
from sqlalchemy import func, desc, or_
|
||||||
from sqlalchemy.orm import joinedload
|
from sqlalchemy.orm import joinedload
|
||||||
|
from sqlalchemy.orm.exc import ObjectDeletedError
|
||||||
|
|
||||||
from app import s3
|
from app import s3
|
||||||
from app.alias_utils import nb_email_log_for_mailbox
|
from app.alias_utils import nb_email_log_for_mailbox
|
||||||
|
@ -69,11 +70,15 @@ def notify_trial_end():
|
||||||
for user in User.filter(
|
for user in User.filter(
|
||||||
User.activated.is_(True), User.trial_end.isnot(None), User.lifetime.is_(False)
|
User.activated.is_(True), User.trial_end.isnot(None), User.lifetime.is_(False)
|
||||||
).all():
|
).all():
|
||||||
if user.in_trial() and arrow.now().shift(
|
try:
|
||||||
days=3
|
if user.in_trial() and arrow.now().shift(
|
||||||
) > user.trial_end >= arrow.now().shift(days=2):
|
days=3
|
||||||
LOG.d("Send trial end email to user %s", user)
|
) > user.trial_end >= arrow.now().shift(days=2):
|
||||||
send_trial_end_soon_email(user)
|
LOG.d("Send trial end email to user %s", user)
|
||||||
|
send_trial_end_soon_email(user)
|
||||||
|
# happens if user has been deleted in the meantime
|
||||||
|
except ObjectDeletedError:
|
||||||
|
LOG.i("user has been deleted")
|
||||||
|
|
||||||
|
|
||||||
def delete_logs():
|
def delete_logs():
|
||||||
|
|
Loading…
Reference in a new issue