Commit d8771860 authored by Vincent Pelletier's avatar Vincent Pelletier

Do not conditionaly define locking classes, so that they can be available...

Do not conditionaly define locking classes, so that they can be available independently from VERBOSE_LOCKING value for finer-grained lock tracing.


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@1217 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 37bc1b1b
......@@ -23,12 +23,11 @@ __all__ = ['Lock', 'RLock']
VERBOSE_LOCKING = False
if VERBOSE_LOCKING:
import traceback
import sys
import os
import traceback
import sys
import os
class LockUser(object):
class LockUser(object):
def __init__(self, level=0):
self.ident = currentThread().getName()
# This class is instanciated from a place desiring to known what
......@@ -54,7 +53,7 @@ if VERBOSE_LOCKING:
def formatStack(self):
return ''.join(traceback.format_list(self.stack))
class VerboseLock(object):
class VerboseLockBase(object):
def __init__(self, reentrant=False):
self.reentrant = reentrant
self.owner = None
......@@ -99,7 +98,7 @@ if VERBOSE_LOCKING:
def __repr__(self):
return '<%s@%X>' % (self.__class__.__name__, id(self))
class RLock(VerboseLock):
class VerboseRLock(VerboseLockBase):
def __init__(self, verbose=None):
VerboseLock.__init__(self, reentrant=True)
self.lock = threading_RLock()
......@@ -110,7 +109,7 @@ if VERBOSE_LOCKING:
def _is_owned(self):
return self.lock._is_owned()
class Lock(VerboseLock):
class VerboseLock(VerboseLockBase):
def __init__(self, verbose=None):
VerboseLock.__init__(self)
self.lock = threading_Lock()
......@@ -118,6 +117,10 @@ if VERBOSE_LOCKING:
def locked(self):
return self.lock.locked()
_locked = locked
if VERBOSE_LOCKING:
Lock = VerboseLock
RLock = VerboseRLock
else:
Lock = threading_Lock
RLock = threading_RLock
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment