refreshperiod = int(self.refreshperiod * 60)
sleepresult = self.ui.sleep(refreshperiod)
- if sleepresult == 2:
- # Cancel keep-alive, but don't bother terminating threads
- for item in kaobjs:
- item.stopkeepalive(abrupt = 1)
- return sleepresult
- else:
- # Cancel keep-alive and wait for thread to terminate.
- for item in kaobjs:
- item.stopkeepalive(abrupt = 0)
- return sleepresult
+ # Cancel keepalive
+ for item in kaobjs:
+ item.stopkeepalive()
+ return sleepresult
class AccountSynchronizationMixin:
def syncrunner(self):
from offlineimap import imaplibutil, imaputil, threadutil
from offlineimap.ui import UIBase
from threading import *
-import thread, hmac, os
+import thread, hmac, os, time
import base64
try:
ui.debug('imap', 'keepalive thread started')
while 1:
ui.debug('imap', 'keepalive: top of loop')
- event.wait(timeout)
+ time.sleep(timeout)
ui.debug('imap', 'keepalive: after wait')
if event.isSet():
ui.debug('imap', 'keepalive: event is set; exiting')
"""The default implementation will do nothing."""
pass
- def stopkeepalive(self, abrupt = 0):
- """Stop keep alive. If abrupt is 1, stop it but don't bother waiting
+ def stopkeepalive(self):
+ """Stop keep alive, but don't bother waiting
for the threads to terminate."""
pass
self.kathread.setDaemon(1)
self.kathread.start()
- def stopkeepalive(self, abrupt = 0):
+ def stopkeepalive(self):
if not hasattr(self, 'kaevent'):
# Keepalive is not active.
return
self.kaevent.set()
- if not abrupt:
- self.kathread.join()
del self.kathread
del self.kaevent