Commit e67bd559 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Add simple lock debug output

Currently it can only be enabled by modifying utils.py, but we can
add a command line parameter later if needed.

Reviewed-by: schreiberal
parent e50c3a9e
......@@ -52,6 +52,7 @@ _locksheld = []
_re_shell_unquoted = re.compile('^[-.,=:/_+@A-Za-z0-9]+$')
debug = False
debug_locks = False
no_fork = False
......@@ -1202,14 +1203,22 @@ def LockedMethod(fn):
object's own lock which is hardcoded to '_lock'.
"""
def _LockDebug(*args, **kwargs):
if debug_locks:
logging.debug(*args, **kwargs)
def wrapper(self, *args, **kwargs):
assert hasattr(self, '_lock')
lock = self._lock
_LockDebug("Waiting for %s", lock)
lock.acquire()
try:
_LockDebug("Acquired %s", lock)
result = fn(self, *args, **kwargs)
finally:
_LockDebug("Releasing %s", lock)
lock.release()
_LockDebug("Released %s", lock)
return result
return wrapper
......
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