siddartha-ravichandran commented on a change in pull request #12801:
URL: https://github.com/apache/airflow/pull/12801#discussion_r536075373
##########
File path: airflow/utils/email.py
##########
@@ -178,14 +180,23 @@ def send_mime_email(e_from: str, e_to: List[str],
mime_msg: MIMEMultipart, dryru
log.debug("No user/password found for SMTP, so logging in with no
authentication.")
if not dryrun:
- conn = smtplib.SMTP_SSL(smtp_host, smtp_port) if smtp_ssl else
smtplib.SMTP(smtp_host, smtp_port)
- if smtp_starttls:
- conn.starttls()
- if smtp_user and smtp_password:
- conn.login(smtp_user, smtp_password)
- log.info("Sent an alert email to %s", e_to)
- conn.sendmail(e_from, e_to, mime_msg.as_string())
- conn.quit()
+ for attempt in range(smtp_retry_limit):
Review comment:
Makes sense, pushed the commit!
##########
File path: airflow/utils/email.py
##########
@@ -178,14 +180,23 @@ def send_mime_email(e_from: str, e_to: List[str],
mime_msg: MIMEMultipart, dryru
log.debug("No user/password found for SMTP, so logging in with no
authentication.")
if not dryrun:
- conn = smtplib.SMTP_SSL(smtp_host, smtp_port) if smtp_ssl else
smtplib.SMTP(smtp_host, smtp_port)
- if smtp_starttls:
- conn.starttls()
- if smtp_user and smtp_password:
- conn.login(smtp_user, smtp_password)
- log.info("Sent an alert email to %s", e_to)
- conn.sendmail(e_from, e_to, mime_msg.as_string())
- conn.quit()
+ for attempt in range(smtp_retry_limit):
+ log.info("Email alerting: attempt %s", str(attempt + 1))
+ try:
+ conn = _get_smtp_connection(smtp_host, smtp_port,
smtp_timeout, smtp_ssl)
+ except smtplib.SMTPServerDisconnected:
+ if attempt < (smtp_retry_limit - 1):
Review comment:
Addressed.
##########
File path: airflow/utils/email.py
##########
@@ -178,14 +180,23 @@ def send_mime_email(e_from: str, e_to: List[str],
mime_msg: MIMEMultipart, dryru
log.debug("No user/password found for SMTP, so logging in with no
authentication.")
if not dryrun:
- conn = smtplib.SMTP_SSL(smtp_host, smtp_port) if smtp_ssl else
smtplib.SMTP(smtp_host, smtp_port)
- if smtp_starttls:
- conn.starttls()
- if smtp_user and smtp_password:
- conn.login(smtp_user, smtp_password)
- log.info("Sent an alert email to %s", e_to)
- conn.sendmail(e_from, e_to, mime_msg.as_string())
- conn.quit()
+ for attempt in range(smtp_retry_limit):
+ log.info("Email alerting: attempt %s", str(attempt + 1))
Review comment:
Addressed.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]