summaryrefslogtreecommitdiffstats
path: root/wallace
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2015-05-26 14:17:18 +0200
committerThomas Bruederli <bruederli@kolabsys.com>2015-05-26 14:17:18 +0200
commita1a7c5fdb86c513b43deb2496f0d1c604ec52f14 (patch)
tree35e5c91f64d3a03c70abdd3f10ab97f95991f773 /wallace
parent0c072d69d677fa7cdad65af563994f6a0098003f (diff)
downloadpykolab-a1a7c5fdb86c513b43deb2496f0d1c604ec52f14.tar.gz
Limit number of retries to send an update notification; fix the smtplib.SMTP.sendmail() mock to also return success status
Diffstat (limited to 'wallace')
-rw-r--r--wallace/module_invitationpolicy.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/wallace/module_invitationpolicy.py b/wallace/module_invitationpolicy.py
index edd23a9..f401b0d 100644
--- a/wallace/module_invitationpolicy.py
+++ b/wallace/module_invitationpolicy.py
@@ -1209,15 +1209,21 @@ def send_update_notification(object, receiving_user, old=None, reply=True):
smtp.set_debuglevel(True)
success = False
+ retries = 5
- while not success:
+ while not success and retries > 0:
try:
success = smtp.sendmail(orgemail, receiving_user['mail'], msg.as_string())
log.debug(_("Sent update notification to %r: %r") % (receiving_user['mail'], success), level=8)
smtp.quit()
+ break
except Exception, e:
log.error(_("SMTP sendmail error: %r") % (e))
- time.sleep(10)
+
+ time.sleep(10)
+ retries -= 1
+
+ return success
def send_cancel_notification(object, receiving_user, deleted=False):