Merge "Add retries to sending emails"

This commit is contained in:
Zuul 2020-05-25 17:23:34 +00:00 committed by Gerrit Code Review
commit 4b9898b2bd
2 changed files with 10 additions and 2 deletions

View File

@ -22,6 +22,8 @@ import argparse
import email
import smtplib
import tenacity
def main():
parser = argparse.ArgumentParser()
@ -47,9 +49,14 @@ def main():
msg = email.message_from_file(f)
tolist = [address.strip() for address in msg['to'].split(",")]
send_email(server, msg, tolist, user=user, pw=pw, debug=args.verbose)
server = smtplib.SMTP(server)
if args.verbose:
@tenacity.retry(wait=tenacity.wait_exponential,
stop=tenacity.stop_after_attempt(4))
def send_email(smtp_server, msg, tolist, user=None, pw=None, debug=False):
server = smtplib.SMTP(smtp_server)
if debug:
server.set_debuglevel(True)
try:
if pw:

View File

@ -20,6 +20,7 @@ jsonschema>=2.6.0
twine>=1.13.0
wheel>=0.34.2
ruamel.yaml>=0.15
tenacity>=6.1.0
# For release notes generation.
Jinja2>=2.6 # BSD License (3 clause)