It's too late, but it is a bit pity....

On 2019/10/30 0:11, Nathan Hartman wrote:

<snip>
After incorporating all the preceding feedback, the function is
considerably longer, but we handle and report errors:
> [[[>    def finish(self):

<snip>

     finally:
       server.quit()
]]]

As I mentioned before (but I couldn't tell what I want, sorry),
smtplib.SMTP.quit() can raise exception. If server.quit() in finally
block has raised an exception and it isn't caught, it will overwrite
the exception raised in try block or re-raised in exception block.

The exception on server.quit() itself doesn't affect the result that
we could send message or not, and there is nothing we can do more
about this SMTP session. So we can catch it, then safely ignore it or
at most log its cause as warning, and continue the transaction.
Even if the cause of exception is fatal, It doesn't directly affect next
attempt to send message.

Cheers,
--
Yasuhito FUTATSUKI <futat...@yf.bsdclub.org>/<futat...@poem.co.jp>

Reply via email to