aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGravatar Nikolaus Rath <Nikolaus@rath.org>2016-10-08 19:26:32 -0700
committerGravatar Nikolaus Rath <Nikolaus@rath.org>2016-10-08 21:26:40 -0700
commitba0462e4012205d639dfdc9e13fb66c2afef6f3b (patch)
tree225ba4ba72881583cdf2b814c7b869ffa69bf30b /test
parentc3b9431fc5092266c17b63afab151273e1df0243 (diff)
Added safe_sleep()
Diffstat (limited to 'test')
-rw-r--r--test/util.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/util.py b/test/util.py
index e8bb9c2..9c379f0 100644
--- a/test/util.py
+++ b/test/util.py
@@ -38,6 +38,20 @@ def umount(mount_process, mnt_dir):
pytest.fail('mount process did not terminate')
+def safe_sleep(secs):
+ '''Like time.sleep(), but sleep for at least *secs*
+
+ `time.sleep` may sleep less than the given period if a signal is
+ received. This function ensures that we sleep for at least the
+ desired time.
+ '''
+
+ now = time.time()
+ end = now + secs
+ while now < end:
+ time.sleep(end - now)
+ now = time.time()
+
# If valgrind and libtool are available, use them
def has_program(name):
try: