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

locking: Convert pipe condition to new timeout class


Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 7e8841bd
......@@ -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.
......
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