diff --git a/head/offlineimap.py b/head/offlineimap.py index f602cfe..569017d 100644 --- a/head/offlineimap.py +++ b/head/offlineimap.py @@ -85,7 +85,8 @@ def syncaccount(accountname, *args): # Connect to the remote server. server = imapserver.IMAPServer(user, passwords[accountname], - host, port, ssl) + host, port, ssl, + config.getint(accountname, "maxconnections")) remoterepos = repository.IMAP.IMAPRepository(config, accountname, server) # Connect to the Maildirs. diff --git a/head/offlineimap/folder/Base.py b/head/offlineimap/folder/Base.py index 726fca0..759f5a6 100644 --- a/head/offlineimap/folder/Base.py +++ b/head/offlineimap/folder/Base.py @@ -17,6 +17,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import __main__ +from threading import * class BaseFolder: def getname(self): diff --git a/head/offlineimap/folder/IMAP.py b/head/offlineimap/folder/IMAP.py index b781f3d..b612e2a 100644 --- a/head/offlineimap/folder/IMAP.py +++ b/head/offlineimap/folder/IMAP.py @@ -127,7 +127,7 @@ class IMAPFolder(BaseFolder): self.messagelist[uid]['flags'] = imaputil.flagsimap2maildir(flags) def addmessagesflags(self, uidlist, flags): - imapobj = self.imapserver.acquireconnection(imapobj) + imapobj = self.imapserver.acquireconnection() try: imapobj.select(self.getfullname()) r = imapobj.uid('store', diff --git a/head/offlineimap/imapserver.py b/head/offlineimap/imapserver.py index 3a89d03..45eabcd 100644 --- a/head/offlineimap/imapserver.py +++ b/head/offlineimap/imapserver.py @@ -18,6 +18,7 @@ from offlineimap import imaplib, imaputil, threadutil from threading import * +import sys class UsefulIMAPMixIn: def getstate(self): @@ -81,6 +82,8 @@ class IMAPServer: self.availableconnections.append(connection) self.connectionlock.release() self.semaphore.release() + print "%d connections used after release" % len(self.assignedconnections) + sys.stdout.flush() def acquireconnection(self): @@ -98,6 +101,8 @@ class IMAPServer: self.assignedconnections.append(imapobj) del(self.availableconnections[0]) self.connectionlock.release() + print "%d connections used after acquire" % len(self.assignedconnections) + sys.stdout.flush() return imapobj self.connectionlock.release() # Release until need to modify data @@ -119,6 +124,8 @@ class IMAPServer: self.connectionlock.acquire() self.assignedconnections.append(imapobj) self.connectionlock.release() + print "%d connections used after acquire" % len(self.assignedconnections) + sys.stdout.flush() return imapobj def connectionwait(self): diff --git a/head/offlineimap/ui/TTY.py b/head/offlineimap/ui/TTY.py index fd5d73f..5873e53 100644 --- a/head/offlineimap/ui/TTY.py +++ b/head/offlineimap/ui/TTY.py @@ -8,6 +8,7 @@ class TTYUI(UIBase): def _msg(s, msg): print msg + sys.stdout.flush() def getpass(s, accountname, config): return getpass("%s: Enter password for %s on %s: " %