offlineimap rev 564
"Automatic Subversion Change Mailer" <[email protected]> Wed, 13 Aug 2003 16:55:42 -0500 (CDT)
| Newsgroups | gmane.mail.imap.offlineimap.subversion |
|---|---|
| Message-ID | <[email protected]> |
You are receiving this message because
all commits get sent to this address.
Author: jgoerzen
Date: 2003-08-13 16:55:37 -0500 (Wed, 13 Aug 2003)
New Revision: 564
Modified:
offlineimap/branches/twisted/offlineimap/accounts.py
Log:
Some starts towards being able to support autorefresh again
Diff:
Modified: offlineimap/branches/twisted/offlineimap/accounts.py
===================================================================
--- offlineimap/branches/twisted/offlineimap/accounts.py 2003-08-13 16:08:33 UTC (rev 563)
+++ offlineimap/branches/twisted/offlineimap/accounts.py 2003-08-13 21:55:37 UTC (rev 564)
@@ -20,6 +20,7 @@
from offlineimap.ui import UIBase
import os
from twisted.internet import defer
+from offlineimap.imaputil import rd
def getaccountlist(customconfig):
@@ -65,10 +66,13 @@
0 if timeout expired, 1 if there was a request to cancel the timer,
and 2 if there is a request to abort the program.
- Also, returns 100 if configured to not sleep at all."""
+ Also, returns 100 if configured to not sleep at all.
+
+ Actually, we return a Deferred and call it with the appropriate values.
+ """
if not self.refreshperiod:
- return 100
+ return rd(100)
kaobjs = []
@@ -81,17 +85,21 @@
item.startkeepalive()
refreshperiod = int(self.refreshperiod * 60)
- sleepresult = self.ui.sleep(refreshperiod)
+ d = self.ui.sleep(refreshperiod)
+ d.addCallback(self.sleeper_result)
+ self.sleepd = d # Keeps it from being garbage collected
+ #return d
+
+ def sleeper_result(self, sleepresult):
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
+ return self.sleepdone(sleepresult)
class AccountSynchronizationMixin:
def syncrunner(self):
@@ -110,17 +118,18 @@
self.statusrepos = offlineimap.repository.LocalStatus.LocalStatusRepository(self.getconf('localrepository'), self)
#print "In nextstep"
- if not self.refreshperiod:
- d = self.sync()
+ d = self.sync()
+ if self.refreshperiod:
+ d.addCallback(self.sleeper)
+ else:
d.addCallback(self.acctdone)
- return d
+ return d
- # FIXME: this needs help
- looping = 1
- while looping:
- d = self.sync()
- looping = self.sleeper() != 2
- return d
+ def sleepdone(self, sleepresult):
+ if sleepresult == 2:
+ self.acctdone(None)
+ return sleepresult
+ self.sleeper()
def acctdone(self, ignore):
self.ui.acctdone(self.name)