Opened 13 years ago
Last modified 13 years ago
#3973 enhancement new
An unexpected exception while sending a message jams the rest of the messages in the queue
Reported by: | Yaniv Aknin | Owned by: | Yaniv Aknin |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | Keywords: | ||
Cc: | Branch: | ||
Author: |
Description
twisted.mail.relaymanager.SmartHostSMTPRelayingManager method checkStateMX (and _checkStateMX) are ran periodically to start SMTP delivery of ready-to-be-delivered queued messages.
If the queue has more than one message, and the handling of one of these messages triggers an unhandled exception for any reason, the other messages will remain 'jammed' in the queue (since the 'bad' message will never be sent, and since it is likely that every time we try to send it we hit the same exception, all other messages will never be evaluated).
While we hope such an unhandled exception should never happen, the possibility is always there and the price of jamming the whole queue is great enough that it may be prudent to place the contents of the loop over the queue in a broad try/except clause and do something with any unhandled exceptions rather than let them clog the queue.
One of the questions is what to do with the unhandled exceptions we trap - I suggest a simple log.err(caught_exception) is sufficient, as when the exception will bubble up to the reactor, that is what the reactor is going to do anyway.
Logging the problem and moving on is definitely a good idea.