[PATCH 0/6] Re: Readd idle again

Nicolas Sebrecht nicolas.s-dev at laposte.net
Thu May 19 20:35:04 BST 2011


On Thu, May 19, 2011 at 03:02:25PM -0400, Ethan Glasser-Camp wrote:
> 
> Hi guys,
> 
> Please find the followign six patches to readd IDLE, which are the
> same as yesterday but with minor changes and clarifications to respond
> to Nicholas's criticism.  I guess if I were really slick I'd only send
> updated patches, but I'm not that slick :) Anyone want to provide
> pointers?
> 
> Changes:
> 
> - remove unneeded time import (patch 3)
> - warn if IDLE is not supported by server (patch 4)
> - rename variables so as to clarify imaplib2's "error" callback (patch 6)
> - put the comment warning that we can't do a NOOP on a bad connection
>   before the if checking for a bad connection for clarity (patch 6)
> - document shortcomings of IDLE and mark it as EXPERIMENTAL
>   in offlineimap.conf (patch 1)

I'm missing the interdiff. I created it this time:

diff --git a/docs/MANUAL.rst b/docs/MANUAL.rst
index 62b0d3b..26f31a6 100644
--- a/docs/MANUAL.rst
+++ b/docs/MANUAL.rst
@@ -288,6 +288,17 @@ KNOWN BUGS
     last stable version and send us a report to the mailing list including the
     full log.
 
+* IDLE support is incomplete and experimental.  Bugs may be encountered.
+
+  * No hook exists for "run after an IDLE response".  Email will
+    show up, but may not be processed until the next refresh cycle.
+
+  * nametrans may not be supported correctly.
+
+  * IMAP IDLE <-> IMAP IDLE doesn't work yet.
+
+  * IDLE may only work "once" per refresh.  If you encounter this bug,
+    please send a report to the list!
 
 SEE ALSO
 ========
diff --git a/offlineimap.conf b/offlineimap.conf
index 39cded6..9329c66 100644
--- a/offlineimap.conf
+++ b/offlineimap.conf
@@ -372,6 +372,10 @@ remoteuser = username
 #     maxconnections - to be at least the number of folders you give
 #     holdconnectionopen - to be true
 #     keepalive - to be 29 minutes unless you specify otherwise
+#
+# This feature isn't complete and may well have problems. BE AWARE THIS
+# IS EXPERIMENTAL STUFF.  See the manual for more details.
+#
 # This option should return a Python list. For example
 #
 # idlefolders = ['INBOX', 'INBOX.Alerts']
diff --git a/offlineimap/imapserver.py b/offlineimap/imapserver.py
index b24f355..37d80f0 100644
--- a/offlineimap/imapserver.py
+++ b/offlineimap/imapserver.py
@@ -21,7 +21,6 @@ from offlineimap.ui import getglobalui
 from threading import Lock, BoundedSemaphore, Thread, Event, currentThread
 from thread import get_ident	# python < 2.6 support
 import offlineimap.accounts
-import time
 import hmac
 import socket
 import base64
@@ -408,7 +407,8 @@ class IdleThread(object):
             self.needsync = False
             self.imapaborted = False
             def callback(args):
-                if args[2] is None:
+                result, cb_arg, exc_data = args
+                if exc_data is None:
                     if not self.event.isSet():
                         self.needsync = True
                         self.event.set()
@@ -422,11 +422,14 @@ class IdleThread(object):
             if "IDLE" in imapobj.capabilities:
                 imapobj.idle(callback=callback)
             else:
+                self.ui = getglobalui()
+                ui.warn("IMAP IDLE not supported on connection to %s; falling back to no-op"
+                        %(imapobj.identifier,))
                 imapobj.noop()
             self.event.wait()
             if self.event.isSet():
+                # Can't NOOP on a bad connection.
                 if not self.imapaborted:
-                    # Can't NOOP on a bad connection.
                     imapobj.noop()
                     # We don't do event.clear() so that we'll fall out
                     # of the loop next time around.


> Once again, I hope you can apply this :)

-- 
Nicolas Sebrecht




More information about the OfflineIMAP-project mailing list