Commit b6b87034 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

locking, mcpu: Ensure timeout is always >= 0.0


Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent e4335b5b
......@@ -783,7 +783,7 @@ class LockSet:
calc_remaining_timeout = lambda: None
else:
start = time.time()
calc_remaining_timeout = lambda: (start + timeout) - time.time()
calc_remaining_timeout = lambda: max(0.0, (start + timeout) - time.time())
try:
if names is not None:
......
......@@ -136,7 +136,8 @@ class _LockAttemptTimeoutStrategy(object):
remaining_timeout += ((self._random_fn() * variation_range) -
(variation_range * 0.5))
assert remaining_timeout >= 0.0, "Timeout must be positive"
# Make sure timeout is >= 0
remaining_timeout = max(0.0, remaining_timeout)
return remaining_timeout
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment