diff options
author | Thomas Bruederli <bruederli@kolabsys.com> | 2015-05-26 14:17:18 +0200 |
---|---|---|
committer | Thomas Bruederli <bruederli@kolabsys.com> | 2015-05-26 14:17:18 +0200 |
commit | a1a7c5fdb86c513b43deb2496f0d1c604ec52f14 (patch) | |
tree | 35e5c91f64d3a03c70abdd3f10ab97f95991f773 /wallace/module_invitationpolicy.py | |
parent | 0c072d69d677fa7cdad65af563994f6a0098003f (diff) | |
download | pykolab-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/module_invitationpolicy.py')
-rw-r--r-- | wallace/module_invitationpolicy.py | 10 |
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): |