From f369961a87d2476066447d3dcdd41d0f515bafd2 Mon Sep 17 00:00:00 2001 From: Sebastian Spaeth Date: Mon, 12 Sep 2011 10:37:53 +0200 Subject: [PATCH] IMAP IDLE cleanup(1): Move idle callback out of loop Don't redefine the idle callback function on every run in the while loop, define it once when we enter the function. Signed-off-by: Sebastian Spaeth Signed-off-by: Nicolas Sebrecht --- offlineimap/imapserver.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/offlineimap/imapserver.py b/offlineimap/imapserver.py index 05d8111..a07cdc8 100644 --- a/offlineimap/imapserver.py +++ b/offlineimap/imapserver.py @@ -493,21 +493,22 @@ class IdleThread(object): ui.unregisterthread(currentThread()) def idle(self): + def callback(args): + result, cb_arg, exc_data = args + if exc_data is None: + if not self.event.isSet(): + self.needsync = True + self.event.set() + else: + # We got an "abort" signal. + self.imapaborted = True + self.stop() + while True: if self.event.isSet(): return self.needsync = False self.imapaborted = False - def callback(args): - result, cb_arg, exc_data = args - if exc_data is None: - if not self.event.isSet(): - self.needsync = True - self.event.set() - else: - # We got an "abort" signal. - self.imapaborted = True - self.stop() success = False # successfully selected FOLDER? while not success: