Revision 185192f2
b/lib/mcpu.py | ||
---|---|---|
288 | 288 |
" or node resources") |
289 | 289 |
|
290 | 290 |
|
291 |
def _LockList(names): |
|
292 |
"""If 'names' is a string, make it a single-element list. |
|
293 |
|
|
294 |
@type names: list or string |
|
295 |
@param names: Lock names |
|
296 |
@rtype: a list of strings |
|
297 |
@return: if 'names' argument is an iterable, a list of it; |
|
298 |
if it's a string, make it a one-element list |
|
299 |
|
|
300 |
""" |
|
301 |
return [names] if isinstance(names, basestring) else list(names) |
|
302 |
|
|
303 |
|
|
291 | 304 |
class Processor(object): |
292 | 305 |
"""Object which runs OpCodes""" |
293 | 306 |
DISPATCH_TABLE = _ComputeDispatchTable() |
... | ... | |
360 | 373 |
else: |
361 | 374 |
names = locking.LOCKSET_NAME |
362 | 375 |
|
363 |
if isinstance(names, str): |
|
364 |
names = [names] |
|
376 |
names = _LockList(names) |
|
365 | 377 |
|
366 | 378 |
levelname = locking.LEVEL_NAMES[level] |
367 | 379 |
|
... | ... | |
500 | 512 |
lu.wconfdlocks = self.wconfd.Client().ListLocks(self._wconfdcontext) |
501 | 513 |
else: |
502 | 514 |
# Adding locks |
503 |
add_locks = lu.add_locks[level] |
|
504 |
if isinstance(add_locks, str): |
|
505 |
add_locks = [add_locks] |
|
515 |
add_locks = _LockList(lu.add_locks[level]) |
|
506 | 516 |
lu.remove_locks[level] = add_locks |
507 | 517 |
|
508 | 518 |
try: |
... | ... | |
536 | 546 |
result = self._LockAndExecLU(lu, level + 1, calc_timeout) |
537 | 547 |
finally: |
538 | 548 |
if level in lu.remove_locks: |
549 |
remove_locks = _LockList(lu.remove_locks[level]) |
|
539 | 550 |
levelname = locking.LEVEL_NAMES[level] |
540 | 551 |
request = [["%s/%s" % (levelname, lock), "release"] |
541 |
for lock in lu.remove_locks[level]]
|
|
552 |
for lock in remove_locks]
|
|
542 | 553 |
blocked = \ |
543 | 554 |
self.wconfd.Client().TryUpdateLocks(self._wconfdcontext, |
544 | 555 |
request) |
Also available in: Unified diff