diff --git a/lib/locking.py b/lib/locking.py index f13d7b23f5549298c3e885598d1cf04006a74cdb..b02766191af52506175ef6bca7016ad0b234b307 100644 --- a/lib/locking.py +++ b/lib/locking.py @@ -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: diff --git a/lib/mcpu.py b/lib/mcpu.py index 647a69a7d5d36f4364956257f7ec992bdba64fb5..d53bd58f11461e84d9f06ca17b4b2ba9d00ecb8b 100644 --- a/lib/mcpu.py +++ b/lib/mcpu.py @@ -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