Remove MultiLock implementation

Currently the Curses code is broken. Importing offlineimap.ui.Curses
will not succeed due to cyclic imports (threadutils imports ui, but ui
wants threadutils.MultiLock). So Curses cannot be chosen.

Incidentally, the only part in the code that uses "MultiLock" is the
Curses UI, to prevent concurrent access from several threads to the
ui-internal thread list and to IO resources such as the
screen. Fortunately for these purposes we don't need a MultiLock, so we
can do away with that implementation completely. A simple RLock that
allows us to have a thread "own" a lock and makes other threads wanting
access to the resource wait until the owning thread is finished.

The MultiLock implementation looked a bit weird, so simplifying code
here is a good thing, it might well be that we fix some "hangs" that
have been reported (and that would only ever occur with the Curses UI).

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Sebastian Spaeth
2011-01-25 13:24:52 +01:00
committed by Nicolas Sebrecht
parent fa60f3f9b7
commit 83a85bb3fb
3 changed files with 17 additions and 56 deletions

View File

@ -16,10 +16,9 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
from threading import *
from threading import RLock, currentThread
from offlineimap.ui.UIBase import UIBase
import thread
from offlineimap.threadutil import MultiLock
class BlinkenBase:
"""This is a mix-in class that should be mixed in with either UIBase
@ -85,7 +84,8 @@ class BlinkenBase:
def init_banner(s):
s.availablethreadframes = {}
s.threadframes = {}
s.tflock = MultiLock()
#tflock protects the s.threadframes manipulation to only happen from 1 thread
s.tflock = RLock()
def threadExited(s, thread):
threadid = thread.threadid