From 04e367fc272c8edb3bcc21279f4673d9f3a07ca7 Mon Sep 17 00:00:00 2001 From: Patrick Ulbrich Date: Fri, 20 Jan 2012 19:40:02 +0100 Subject: [PATCH] make sure idlers can't have a connection nullptr --- Mailnag/daemon/idler.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Mailnag/daemon/idler.py b/Mailnag/daemon/idler.py index 68c5054..8202892 100644 --- a/Mailnag/daemon/idler.py +++ b/Mailnag/daemon/idler.py @@ -23,6 +23,7 @@ # import threading +import time from daemon.imaplib2 import AUTH class Idler(object): @@ -68,9 +69,14 @@ class Idler(object): def callback(args): if (args[2] != None) and (args[2][0] is self._conn.abort): - # connection has been reset by provider -> reopen - print "Idler thread for account '%s' reconnected" % self._account.name - self._conn = self._account.get_connection(use_existing = False) + # connection has been reset by provider -> try to reconnect + print "Idler thread for account '%s' has been disconnected" % self._account.name + self._conn = None + while (self._conn == None) and (not self._event.isSet()): + print "Trying to reconnect account '%s'" % self._account.name + self._conn = self._account.get_connection(use_existing = False) + if self._conn == None: time.sleep(60 * 5) # don't hammer + if self._conn != None: self._select(self._conn, self._account.folder)