From: John Spray Date: Sun, 25 May 2014 16:34:08 +0000 (+0100) Subject: pybind/rados: Fix timeouts for small t X-Git-Tag: v0.83~146^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4c22c6f9d39fa566c447daeb843d88c51425a9d5;p=ceph.git 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 --- 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