<p>A dirty hack with the below patch somewhat works (error but no hung), and I also raise <code>rxzero</code> upper limit to 100 instead of 5.</p>

<pre><code>--- /Users/monson/project/offlineimap/offlineimap/imapserver.py 2015-08-13 18:03:03.000000000 +0800
+++ /usr/local/Cellar/offline-imap/6.5.7/libexec/offlineimap/imapserver.py  2015-08-13 16:34:03.000000000 +0800
@@ -159,7 +159,10 @@

         if connection is None: return #noop on bad connection
         self.connectionlock.acquire()
-        self.assignedconnections.remove(connection)
+        try:
+            self.assignedconnections.remove(connection)
+        except ValueError:
+            pass
         # Don't reuse broken connections
         if connection.Terminate or drop_conn:
             connection.logout()
</code></pre>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br>Reply to this email directly or <a href="https://github.com/OfflineIMAP/offlineimap/issues/205#issuecomment-130602316">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AKFSECXn3asSvhfNDnu2-2jCtAf3Np4pks5onGTLgaJpZM4EjkWN.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/OfflineIMAP/offlineimap/issues/205#issuecomment-130602316"></link>
  <meta itemprop="name" content="View Issue"></meta>
</div>
<meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>