Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
snf-ganeti
Commits
ea3f80bf
Commit
ea3f80bf
authored
Mar 04, 2008
by
Guido Trotter
Browse files
LockSet: collapse two try/except into one
Reviewed-by: imsnah
parent
9a39f854
Changes
1
Hide whitespace changes
Inline
Side-by-side
lib/locking.py
View file @
ea3f80bf
...
...
@@ -413,17 +413,9 @@ class LockSet:
for
(
lname
,
lock
)
in
acquire_list
:
try
:
lock
.
acquire
(
shared
=
shared
)
# raises LockError if the lock is deleted
try
:
# now the lock cannot be deleted, we have it!
self
.
_add_owned
(
lname
)
acquired
.
add
(
lname
)
except
:
# We shouldn't have problems adding the lock to the owners list, but
# if we did we'll try to release this lock and re-raise exception.
# Of course something is going to be really wrong, after this.
lock
.
release
()
raise
# now the lock cannot be deleted, we have it!
self
.
_add_owned
(
lname
)
acquired
.
add
(
lname
)
except
(
errors
.
LockError
):
if
self
.
__lock
.
_is_owned
():
# We are acquiring all the set, it doesn't matter if this particular
...
...
@@ -435,6 +427,13 @@ class LockSet:
self
.
__lockdict
[
lname
].
release
()
self
.
_del_owned
(
lname
)
raise
errors
.
LockError
(
'non-existing lock in set (%s)'
%
name_fail
)
except
:
# We shouldn't have problems adding the lock to the owners list, but
# if we did we'll try to release this lock and re-raise exception.
# Of course something is going to be really wrong, after this.
if
lock
.
_is_owned
():
lock
.
release
()
raise
except
:
# If something went wrong and we had the set-lock let's release it...
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment