diff --git a/openstack_releases/cmds/mail.py b/openstack_releases/cmds/mail.py index ab1cd0684b..433e905be2 100644 --- a/openstack_releases/cmds/mail.py +++ b/openstack_releases/cmds/mail.py @@ -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: diff --git a/requirements.txt b/requirements.txt index 4da04a7a53..baf80dc7ee 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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)