From a298fd5ae8a311ac213f4127355d6a468824235b Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Mon, 22 Nov 2010 21:57:59 +0100
Subject: [PATCH] utils._RunCmdPipe: fix poller timeout usage
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This patch makes a simple timeout test (e.g. testTimeoutKill) go from
13K poll syscalls to just 6. The code didn't take into account that
RunningTimeout talks in seconds while the poller object expects
milliseconds.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: RenΓ© Nussbaumer <rn@google.com>
---
 lib/utils.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/utils.py b/lib/utils.py
index 71134bc6b..9535d5355 100644
--- a/lib/utils.py
+++ b/lib/utils.py
@@ -567,7 +567,7 @@ def _RunCmdPipe(cmd, env, via_shell, cwd, interactive, timeout,
 
     while fdmap:
       if poll_timeout:
-        current_timeout = poll_timeout()
+        current_timeout = poll_timeout() * 1000
         if current_timeout < 0:
           if linger_timeout is None:
             logging.warning(msg_timeout)
@@ -575,7 +575,7 @@ def _RunCmdPipe(cmd, env, via_shell, cwd, interactive, timeout,
               timeout_action = _TIMEOUT_TERM
               IgnoreProcessNotFound(os.kill, child.pid, signal.SIGTERM)
             linger_timeout = RunningTimeout(_linger_timeout, True).Remaining
-          lt = linger_timeout()
+          lt = linger_timeout() * 1000
           if lt < 0:
             break
 
-- 
GitLab