Revision 8b68f394 lib/locking.py
b/lib/locking.py | ||
---|---|---|
382 | 382 |
# First we look the locks up on __lockdict. We have no way of being sure |
383 | 383 |
# they will still be there after, but this makes it a lot faster should |
384 | 384 |
# just one of them be the already wrong |
385 |
try:
|
|
386 |
for lname in names:
|
|
385 |
for lname in names:
|
|
386 |
try:
|
|
387 | 387 |
lock = self.__lockdict[lname] # raises KeyError if the lock is not there |
388 | 388 |
acquire_list.append((lname, lock)) |
389 |
except (KeyError): |
|
390 |
raise errors.LockError('non-existing lock in set (%s)' % lname) |
|
389 |
except (KeyError):
|
|
390 |
raise errors.LockError('non-existing lock in set (%s)' % lname)
|
|
391 | 391 |
|
392 | 392 |
# Now acquire_list contains a sorted list of resources and locks we want. |
393 | 393 |
# In order to get them we loop on this (private) list and acquire() them. |
394 | 394 |
# We gave no real guarantee they will still exist till this is done but |
395 | 395 |
# .acquire() itself is safe and will alert us if the lock gets deleted. |
396 |
try:
|
|
397 |
for (lname, lock) in acquire_list:
|
|
396 |
for (lname, lock) in acquire_list:
|
|
397 |
try:
|
|
398 | 398 |
lock.acquire(shared=shared) # raises LockError if the lock is deleted |
399 | 399 |
try: |
400 | 400 |
# now the lock cannot be deleted, we have it! |
... | ... | |
406 | 406 |
lock.release() |
407 | 407 |
raise |
408 | 408 |
|
409 |
except (errors.LockError): |
|
410 |
name_fail = lname |
|
411 |
for lname in self._list_owned(): |
|
412 |
self.__lockdict[lname].release() |
|
413 |
self._del_owned(lname) |
|
414 |
raise errors.LockError('non-existing lock in set (%s)' % name_fail) |
|
409 |
except (errors.LockError):
|
|
410 |
name_fail = lname
|
|
411 |
for lname in self._list_owned():
|
|
412 |
self.__lockdict[lname].release()
|
|
413 |
self._del_owned(lname)
|
|
414 |
raise errors.LockError('non-existing lock in set (%s)' % name_fail)
|
|
415 | 415 |
|
416 | 416 |
return True |
417 | 417 |
|
Also available in: Unified diff