On Sun, Oct 20, 2019 at 2:16 AM Yasuhito FUTATSUKI <futatuki_at_poem.co.jp>
wrote:
> 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.
>
(snip)
> > 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.
I think the attached patch accomplishes that. (I'm not putting it inline
because it's 200 lines long! Most of them due to indent changes.)
I'd appreciate a review!
The changes are pretty basic:
* A new exception class is added: MessageSendFailure.
* The contents of SMTPOutput.finish() are wrapped in try..except. We
catch any smtplib.SMTPException, print an error to stderr, and raise
MessageSendFailure.
* In all classes' generate(), we wrap the body of the for-loop in a
try..except. We catch MessageSendFailure and increment a counter;
generate() returns the value of the counter.
* In main, the return value of messenger.generate() is returned to
main's caller.
* In the __main__ program, the call to svn.core.run_app() is wrapped
with sys.exit().
Received on 2019-10-23 17:48:48 CEST