Active waiting?

Alvaro Gamez alvaro.gamez at hazent.com
Mon Mar 23 17:27:00 UTC 2015


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

>
> 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 laposte.net>
>

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/imapserver.py b/offlineimap/imapserver.py
index f0b2248..21c3c5c 100644
--- a/offlineimap/imapserver.py
+++ b/offlineimap/imapserver.py
@@ -596,7 +596,7 @@ class IMAPServer:
                 threads.append(idler)

             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: <http://lists.alioth.debian.org/pipermail/offlineimap-project/attachments/20150323/3a3180f1/attachment.html>


More information about the OfflineIMAP-project mailing list