refactoring: simplify the semaphorewait logic
The semaphorewait()/waitforthread() logic is usefull for IMAP starting connections. We actually use it in imapserver only. This patch removes the over-engineered factorized methods. It tend to simplify the code by cleaning out a chain of two direct calls with no other processes. Reviewed-by: Sebastian Spaeth <Sebastian@SSpaeth.de> Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
parent
d5493fe894
commit
136237b7dc
@ -37,11 +37,6 @@ class BaseFolder(object):
|
|||||||
false otherwise. Probably only IMAP will return true."""
|
false otherwise. Probably only IMAP will return true."""
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def waitforthread(self):
|
|
||||||
"""For threading folders, waits until there is a resource available
|
|
||||||
before firing off a thread. For all others, returns immediately."""
|
|
||||||
pass
|
|
||||||
|
|
||||||
def getcopyinstancelimit(self):
|
def getcopyinstancelimit(self):
|
||||||
"""For threading folders, returns the instancelimitname for
|
"""For threading folders, returns the instancelimitname for
|
||||||
InstanceLimitedThreads."""
|
InstanceLimitedThreads."""
|
||||||
|
@ -300,7 +300,8 @@ class IMAPServer:
|
|||||||
to copy messages, then have them all wait for 3 available connections.
|
to copy messages, then have them all wait for 3 available connections.
|
||||||
It's OK if we have maxconnections + 1 or 2 threads, which is what
|
It's OK if we have maxconnections + 1 or 2 threads, which is what
|
||||||
this will help us do."""
|
this will help us do."""
|
||||||
threadutil.semaphorewait(self.semaphore)
|
self.semaphore.acquire()
|
||||||
|
self.semaphore.release()
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
# Make sure I own all the semaphores. Let the threads finish
|
# Make sure I own all the semaphores. Let the threads finish
|
||||||
|
@ -42,10 +42,6 @@ def semaphorereset(semaphore, originalstate):
|
|||||||
for i in range(originalstate):
|
for i in range(originalstate):
|
||||||
semaphore.release()
|
semaphore.release()
|
||||||
|
|
||||||
def semaphorewait(semaphore):
|
|
||||||
semaphore.acquire()
|
|
||||||
semaphore.release()
|
|
||||||
|
|
||||||
class threadlist:
|
class threadlist:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.lock = Lock()
|
self.lock = Lock()
|
||||||
|
Loading…
Reference in New Issue
Block a user