imaplibutil: Have SELECT throw an OfflineImapError when the connection died
Imapserver.acquireconnection will succeed even whent the server connection has been terminated and the first IMAP operation will throw an exception. Often this is the folder SELECT operation (e.g. after an idle timeout), as has been reported by John Wiegley. Catch this case and throw an OfflineImapError with severity FOLDER_RETRY to notify consumers that they are supposed to retry. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de> Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
parent
7bc45507cb
commit
61fffd5c5f
@ -49,7 +49,14 @@ class UsefulIMAPMixIn:
|
||||
return
|
||||
# Wipe out all old responses, to maintain semantics with old imaplib2
|
||||
del self.untagged_responses[:]
|
||||
result = self.__class__.__bases__[1].select(self, mailbox, readonly)
|
||||
try:
|
||||
result = self.__class__.__bases__[1].select(self, mailbox, readonly)
|
||||
except self.abort, e:
|
||||
# self.abort is raised when we are supposed to retry
|
||||
errstr = "Server '%s' closed connection, error on SELECT '%s'. Ser"\
|
||||
"ver said: %s" % (self.host, mailbox, e.args[0])
|
||||
severity = OfflineImapError.ERROR.FOLDER_RETRY
|
||||
raise OfflineImapError(errstr, severity)
|
||||
if result[0] != 'OK':
|
||||
#in case of error, bail out with OfflineImapError
|
||||
errstr = "Error SELECTing mailbox '%s', server reply:\n%s" %\
|
||||
|
Loading…
Reference in New Issue
Block a user