If we loop, exit the account synchronization after 3 failed attempts

This should get rid of intermittent network failures, but lets us bail
out on permanent errors.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Sebastian Spaeth 2011-05-04 16:45:28 +02:00 committed by Nicolas Sebrecht
parent 4608d14836
commit f3774343db

View File

@ -202,8 +202,8 @@ class SyncableAccount(Account):
self.localrepos = Repository(self, 'local') self.localrepos = Repository(self, 'local')
self.statusrepos = Repository(self, 'status') self.statusrepos = Repository(self, 'status')
# Loop account synchronization if needed # Loop account sync if needed (bail out after 3 failures)
looping = True looping = 3
while looping: while looping:
try: try:
try: try:
@ -214,16 +214,20 @@ class SyncableAccount(Account):
self.ui.warn(e.reason) self.ui.warn(e.reason)
#stop looping and bubble up Exception if needed #stop looping and bubble up Exception if needed
if e.severity >= OfflineImapError.ERROR.REPO: if e.severity >= OfflineImapError.ERROR.REPO:
looping = 0 if looping:
if e.severity > OfflineImapError.ERROR.REPO: looping -= 1
if e.severity >= OfflineImapError.ERROR.CRITICAL:
raise raise
except: except:
self.ui.warn("Error occured attempting to sync "\ self.ui.warn("Error occured attempting to sync "\
"account '%s':\n"% (self, traceback.format_exc())) "account '%s':\n"% (self, traceback.format_exc()))
else:
# after success sync, reset the looping counter to 3
if self.refreshperiod:
looping = 3
finally: finally:
looping = looping and \ if self.sleeper(siglistener) >= 2:
self.refreshperiod and \ looping = 0
self.sleeper(siglistener) != 2
self.ui.acctdone(self.name) self.ui.acctdone(self.name)