Active waiting?

Alvaro G. M. alvaro.gamez at hazent.com
Wed Mar 25 20:50:53 GMT 2015


On Wed Mar 25 21:40:14 2015 Nicolas Sebrecht <nicolas.s-dev at laposte.net> wrote:
> On Mon, Mar 23, 2015 at 09:49:58PM +0100, Nicolas Sebrecht wrote:
> 
> > To get quicker react on events, you could try something like that:
> > 
> > nloop = timeout / 30
> > while nloop > 0:
> > if event.isSet():
> > break
> > time.sleep(30)
> > nloop -= 1
> > 
> > which enables to react each 30 seconds at most for events.
> 
> Did you test the above snippet by any chance? I consider including it in
> the mainline.

I haven't had the time yet, but if time.sleep() really pauses without internal active waiting that is definitely an improvement and the 30 seconds delay is totally acceptable.

If I have a moment tomorrow I'll try that. Another thing I was considering as a work around was to completely remove keepalive timeout functionality and place a cron job to restart offlineimap every 30 minutes, but I don't know if that would be better for battery life or not, since startup has its own peak of disk access and CPU use.





More information about the OfflineIMAP-project mailing list