Commit d05cf6fa authored by Iustin Pop's avatar Iustin Pop
Browse files

utils._RunCmdPipe: simplify the timeout logic



There are two issues: first, it's simpler to assign directly to pt
instead of via another local variable. Second, this code doesn't make
sense:
  if lt < 0:
    break
  pt = max(0, lt)

If lt is indeed < 0, then the code will break. Otherwise, lt ≥ 0, and
max(0, lt) will always be equal to lt. So we remove the extra
assignment.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
parent a298fd5a
......@@ -567,21 +567,17 @@ def _RunCmdPipe(cmd, env, via_shell, cwd, interactive, timeout,
while fdmap:
if poll_timeout:
current_timeout = poll_timeout() * 1000
if current_timeout < 0:
pt = poll_timeout() * 1000
if pt < 0:
if linger_timeout is None:
logging.warning(msg_timeout)
if child.poll() is None:
timeout_action = _TIMEOUT_TERM
IgnoreProcessNotFound(os.kill, child.pid, signal.SIGTERM)
linger_timeout = RunningTimeout(_linger_timeout, True).Remaining
lt = linger_timeout() * 1000
if lt < 0:
pt = linger_timeout() * 1000
if pt < 0:
break
pt = max(0, lt)
else:
pt = current_timeout
else:
pt = None
......
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