On 2019/10/20 13:46, Nathan Hartman wrote:
> From the "Closing Old Issues" department:
>
> SVN-1804: "mailer.py doesn't catch SMTPRecipientsRefused in finish()"
> * Created and last updated in 2004.
> * No comments in more than 15 years.
>
> From my reading of this issue, the impact is that any mail delivery
> hiccup may cause this hook script to exit with an unhandled exception,
> impeding any further mails that it might have sent.
>
> Looking at mailer.py in trunk_at_HEAD, SMTPOutput.finish() doesn't handle
> any exceptions. In particular:
>
> SMTP.login may raise:
> * SMTPHeloError
> * SMTPAuthenticationError
> * SMTPNotSupportedError
> * SMTPException
>
> SMTP.sendmail may raise:
> * SMTPRecipientsRefused
> * SMTPHeloError
> * SMTPSenderRefused
> * SMTPDataError
> * SMTPNotSupportedError
>
> Any of these exceptions cause the same impact. The same is probably
> true of any unhandled exceptions throughout the script, but SMTP errors
> are completely outside our control.
>
> So we have a choice to make:
>
> Either:
>
> Option 1: Handle (and ignore) exceptions in SMTPOutput.finish() to let
> script execution continue after any SMTP failure. This could be as
> simple as wrapping the contents of SMTPOutput.finish() in a "try:" ..
> "except:" (catch-all), where the except block does nothing.
With this approach, I think the script should exit with code
other than 0 if an exception raised, to notify error occured to hook
scripts. Python script exits with code 1 if the script is termitated
by unhandled exceptions, so it can notify on current implementation.
Hook scripts can also watch stderr to log what happens on mailer.py,
etc., though our post-*.tmpl don't do it.
Cheers,
--
Yasuhito FUTATSUKI <futatuki_at_poem.co.jp>
Received on 2019-10-20 08:16:33 CEST