From f4e673fbc7ea833b223975e64304217a8066a66a Mon Sep 17 00:00:00 2001 From: Michael Hanselmann <hansmi@google.com> Date: Thu, 15 Oct 2009 14:38:31 +0200 Subject: [PATCH] locking: Convert pipe condition to new timeout class Signed-off-by: Michael Hanselmann <hansmi@google.com> Reviewed-by: Iustin Pop <iustin@google.com> --- lib/locking.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/locking.py b/lib/locking.py index 0a467a71a..37b2a8b7a 100644 --- a/lib/locking.py +++ b/lib/locking.py @@ -134,10 +134,14 @@ class _SingleNotifyPipeConditionWaiter(object): @param timeout: Timeout for waiting (can be None) """ - start_time = time.time() - remaining_time = timeout + running_timeout = RunningTimeout(timeout, True) + + while True: + remaining_time = running_timeout.Remaining() + + if remaining_time is not None and remaining_time < 0.0: + break - while timeout is None or remaining_time > 0: try: result = self._poller.poll(remaining_time) except EnvironmentError, err: @@ -149,10 +153,6 @@ class _SingleNotifyPipeConditionWaiter(object): if result and result[0][0] == self._fd: break - # Re-calculate timeout if necessary - if timeout is not None: - remaining_time = start_time + timeout - time.time() - class _BaseCondition(object): """Base class containing common code for conditions. -- GitLab