From 4c22c6f9d39fa566c447daeb843d88c51425a9d5 Mon Sep 17 00:00:00 2001 From: John Spray Date: Sun, 25 May 2014 17:34:08 +0100 Subject: [PATCH] pybind/rados: Fix timeouts for small t Previously, if passing a number less than 0.5 for the timeout, operations would always return a failure status code. The same problem would also generate premature timeouts for operations which completed within 0.5s of their timeout deadline. Fix the logic so that we only decrement `countdown` if the thread has not completed when returning from join(). Signed-off-by: John Spray --- src/pybind/rados.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pybind/rados.py b/src/pybind/rados.py index bb249473f562e..f51e744328626 100644 --- a/src/pybind/rados.py +++ b/src/pybind/rados.py @@ -159,7 +159,7 @@ def run_in_thread(target, args, timeout=0): # poll for thread exit while t.is_alive(): t.join(POLL_TIME_INCR) - if timeout: + if timeout and t.is_alive(): countdown = countdown - POLL_TIME_INCR if countdown <= 0: raise KeyboardInterrupt