threading: improve variable names and factorize code

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Nicolas Sebrecht
2016-05-18 02:42:09 +02:00
parent 0addcbabf0
commit e0fdcb3852
5 changed files with 29 additions and 24 deletions

View File

@ -134,7 +134,7 @@ class BaseFolder(object):
return True
def getcopyinstancelimit(self):
def getinstancelimitnamespace(self):
"""For threading folders, returns the instancelimitname for
InstanceLimitedThreads."""
@ -872,7 +872,7 @@ class BaseFolder(object):
if self.suggeststhreads() and not globals.options.singlethreading:
self.waitforthread()
thread = threadutil.InstanceLimitedThread(
self.getcopyinstancelimit(),
self.getinstancelimitnamespace(),
target = self.copymessageto,
name = "Copy message from %s:%s" % (self.repository, self),
args = (uid, dstfolder, statusfolder)

View File

@ -32,6 +32,7 @@ import six
# Globals
CRLF = '\r\n'
MSGCOPY_NAMESPACE = 'MSGCOPY_'
# NB: message returned from getmessage() will have '\n' all over the place,
@ -88,8 +89,8 @@ class IMAPFolder(BaseFolder):
OfflineImapError.ERROR.REPO), None, exc_info()[2])
# Interface from BaseFolder
def getcopyinstancelimit(self):
return 'MSGCOPY_' + self.repository.getname()
def getinstancelimitnamespace(self):
return MSGCOPY_NAMESPACE + self.repository.getname()
# Interface from BaseFolder
def get_uidvalidity(self):