Clear the emailed flag after we actually have sent the email
Looking at the node_down
subscription it seems you are clearing the flag to send an email before you actually sent it:
# Relay has been down for more than the waiting time
if not self.databaseSubscription.emailed:
# Subscriber was not sent an email already
self.databaseSubscription.emailed = True
if self.databaseSubscription.is_active:
# The subscription is active, we should send an email
self.sendEmail()
But let's assume there is an error occurring in the sendEmail()
part that actually prevents the email from getting sent out. I think in that case we should not clear out the emailed flag. Rather, what I assume happening in that case is that we a) might want to log an error and b) re-try sending that mail during the next run, and if successful then set emailed
to True
.
Edited by Georg Koppen