Active waiting?

Alvaro Gamez alvaro.gamez at
Mon Mar 23 17:27:00 GMT 2015

2015-03-23 18:05 GMT+01:00 Nicolas Sebrecht <nicolas.s-dev at>:

> Can't we do something like that?
> --- >8 ---
> Subject: [PATCH] WIP: avoid Queue.get() too much to avoid battery sucking
> From: Nicolas Sebrecht <nicolas.s-dev at>

On my previous email I've found keepalive timer to be the worst offender.
It's not that bad that when sleeping for a couple seconds too many wakeups
arise, but being actively waiting during the whole 29 minutes between
restablishing the IDLE connection is pretty much killing my battery life.

I've never done any python threading programming and don't know much about
offlineimap threading architecture, so I don't know if this is possible,
but could this simple patch solve the issue?

diff --git a/offlineimap/ b/offlineimap/
index f0b2248..21c3c5c 100644
--- a/offlineimap/
+++ b/offlineimap/
@@ -596,7 +596,7 @@ class IMAPServer:

             self.ui.debug('imap', 'keepalive: waiting for timeout')
-            event.wait(timeout)
+            time.sleep(timeout)
             self.ui.debug('imap', 'keepalive: after wait')

             for idler in threads:

Álvaro Gámez Machado
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the OfflineIMAP-project mailing list