Revision f12eadb3
b/lib/locking.py | ||
---|---|---|
179 | 179 |
self.__nwait_shr += 1 |
180 | 180 |
try: |
181 | 181 |
wait = False |
182 |
# If there is an exclusive holder waiting we have to wait. We'll |
|
183 |
# only do this once, though, when we start waiting for the lock. Then |
|
184 |
# we'll just wait while there are no exclusive holders. |
|
182 |
# If there is an exclusive holder waiting we have to wait. |
|
183 |
# We'll only do this once, though, when we start waiting for |
|
184 |
# the lock. Then we'll just wait while there are no |
|
185 |
# exclusive holders. |
|
185 | 186 |
if self.__nwait_exc > 0: |
186 | 187 |
# TODO: if !blocking... |
187 | 188 |
wait = True |
... | ... | |
242 | 243 |
# If there are shared holders waiting (and not just scheduled to pass) |
243 | 244 |
# there *must* be an exclusive holder waiting as well; otherwise what |
244 | 245 |
# were they waiting for? |
245 |
assert (self.__nwait_exc > 0 or self.__npass_shr == self.__nwait_shr), \ |
|
246 |
"Lock sharers waiting while no exclusive is queueing" |
|
246 |
assert (self.__nwait_exc > 0 or |
|
247 |
self.__npass_shr == self.__nwait_shr), \ |
|
248 |
"Lock sharers waiting while no exclusive is queueing" |
|
247 | 249 |
|
248 | 250 |
# If there are no more shared holders either in or scheduled to pass, |
249 | 251 |
# and some exclusive holders are waiting let's wake one up. |
... | ... | |
294 | 296 |
self.__lock.release() |
295 | 297 |
|
296 | 298 |
|
297 |
# Whenever we want to acquire a full LockSet we pass None as the value to acquire.
|
|
298 |
# Hide this behing this nicely named constant. |
|
299 |
# Whenever we want to acquire a full LockSet we pass None as the value |
|
300 |
# to acquire. Hide this behing this nicely named constant.
|
|
299 | 301 |
ALL_SET = None |
300 | 302 |
|
301 | 303 |
|
... | ... | |
461 | 463 |
acquire_list.append((lname, lock)) |
462 | 464 |
except (KeyError): |
463 | 465 |
if self.__lock._is_owned(): |
464 |
# We are acquiring all the set, it doesn't matter if this particular
|
|
465 |
# element is not there anymore. |
|
466 |
# We are acquiring all the set, it doesn't matter if this |
|
467 |
# particular element is not there anymore.
|
|
466 | 468 |
continue |
467 | 469 |
else: |
468 | 470 |
raise errors.LockError('non-existing lock in set (%s)' % lname) |
... | ... | |
481 | 483 |
acquired.add(lname) |
482 | 484 |
except (errors.LockError): |
483 | 485 |
if self.__lock._is_owned(): |
484 |
# We are acquiring all the set, it doesn't matter if this particular
|
|
485 |
# element is not there anymore. |
|
486 |
# We are acquiring all the set, it doesn't matter if this |
|
487 |
# particular element is not there anymore.
|
|
486 | 488 |
continue |
487 | 489 |
else: |
488 | 490 |
name_fail = lname |
... | ... | |
855 | 857 |
assert level in LEVELS_MOD, "Invalid or immutable level %s" % level |
856 | 858 |
assert self._BGL_owned(), ("You must own the BGL before performing other" |
857 | 859 |
" operations") |
858 |
# Check we either own the level or don't own anything from here up.
|
|
859 |
# LockSet.remove() will check the case in which we don't own all the needed
|
|
860 |
# resources, or we have a shared ownership. |
|
860 |
# Check we either own the level or don't own anything from here |
|
861 |
# up. LockSet.remove() will check the case in which we don't own
|
|
862 |
# all the needed resources, or we have a shared ownership.
|
|
861 | 863 |
assert self._is_owned(level) or not self._upper_owned(level), ( |
862 | 864 |
"Cannot remove locks at a level while not owning it or" |
863 | 865 |
" owning some at a greater one") |
Also available in: Unified diff