Revision e67bd559 lib/utils.py
b/lib/utils.py | ||
---|---|---|
52 | 52 |
_re_shell_unquoted = re.compile('^[-.,=:/_+@A-Za-z0-9]+$') |
53 | 53 |
|
54 | 54 |
debug = False |
55 |
debug_locks = False |
|
55 | 56 |
no_fork = False |
56 | 57 |
|
57 | 58 |
|
... | ... | |
1202 | 1203 |
object's own lock which is hardcoded to '_lock'. |
1203 | 1204 |
|
1204 | 1205 |
""" |
1206 |
def _LockDebug(*args, **kwargs): |
|
1207 |
if debug_locks: |
|
1208 |
logging.debug(*args, **kwargs) |
|
1209 |
|
|
1205 | 1210 |
def wrapper(self, *args, **kwargs): |
1206 | 1211 |
assert hasattr(self, '_lock') |
1207 | 1212 |
lock = self._lock |
1213 |
_LockDebug("Waiting for %s", lock) |
|
1208 | 1214 |
lock.acquire() |
1209 | 1215 |
try: |
1216 |
_LockDebug("Acquired %s", lock) |
|
1210 | 1217 |
result = fn(self, *args, **kwargs) |
1211 | 1218 |
finally: |
1219 |
_LockDebug("Releasing %s", lock) |
|
1212 | 1220 |
lock.release() |
1221 |
_LockDebug("Released %s", lock) |
|
1213 | 1222 |
return result |
1214 | 1223 |
return wrapper |
1215 | 1224 |
|
Also available in: Unified diff