Catch terminated connections on the IDLE SELECT operation
Handle the case gracefully where a server has closed an IMAP connection that we want to use for IDLEing. Simply have it dropped and get a new one in this case. THis should get rid of the errors reported by John Wiegley in mail id:"m2sjohd16t.fsf@gmail.com". Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de> Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
parent
61fffd5c5f
commit
f1555ec893
@ -26,7 +26,7 @@ import socket
|
|||||||
import base64
|
import base64
|
||||||
import time
|
import time
|
||||||
import errno
|
import errno
|
||||||
|
from sys import exc_info
|
||||||
from socket import gaierror
|
from socket import gaierror
|
||||||
try:
|
try:
|
||||||
from ssl import SSLError, cert_time_to_seconds
|
from ssl import SSLError, cert_time_to_seconds
|
||||||
@ -456,6 +456,7 @@ class IdleThread(object):
|
|||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.folder = folder
|
self.folder = folder
|
||||||
self.event = Event()
|
self.event = Event()
|
||||||
|
self.ui = getglobalui()
|
||||||
if folder is None:
|
if folder is None:
|
||||||
self.thread = Thread(target=self.noop)
|
self.thread = Thread(target=self.noop)
|
||||||
else:
|
else:
|
||||||
@ -505,13 +506,24 @@ class IdleThread(object):
|
|||||||
self.imapaborted = True
|
self.imapaborted = True
|
||||||
self.stop()
|
self.stop()
|
||||||
|
|
||||||
imapobj = self.parent.acquireconnection()
|
success = False # successfully selected FOLDER?
|
||||||
imapobj.select(self.folder)
|
while not success:
|
||||||
|
imapobj = self.parent.acquireconnection()
|
||||||
|
try:
|
||||||
|
imapobj.select(self.folder)
|
||||||
|
except OfflineImapError, e:
|
||||||
|
if e.severity == OfflineImapError.ERROR.FOLDER_RETRY:
|
||||||
|
# Connection closed, release connection and retry
|
||||||
|
self.ui.error(e, exc_info()[2])
|
||||||
|
self.parent.releaseconnection(imapobj)
|
||||||
|
else:
|
||||||
|
raise e
|
||||||
|
else:
|
||||||
|
success = True
|
||||||
if "IDLE" in imapobj.capabilities:
|
if "IDLE" in imapobj.capabilities:
|
||||||
imapobj.idle(callback=callback)
|
imapobj.idle(callback=callback)
|
||||||
else:
|
else:
|
||||||
ui = getglobalui()
|
self.ui.warn("IMAP IDLE not supported on connection to %s."
|
||||||
ui.warn("IMAP IDLE not supported on connection to %s."
|
|
||||||
"Falling back to old behavior: sleeping until next"
|
"Falling back to old behavior: sleeping until next"
|
||||||
"refresh cycle."
|
"refresh cycle."
|
||||||
%(imapobj.identifier,))
|
%(imapobj.identifier,))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user