@@ -17,7 +17,7 @@ def write_int_to_file(path, i):
17
17
f .write (str (i ))
18
18
19
19
20
- def deterministic_failure (path , timing_map , i , * , name = None ):
20
+ def deterministic_failure (path , timing_map , i , * , default_sleep = 0.01 , name = None ):
21
21
"""A function that can either run normally, run slowly, or raise
22
22
an exception, depending on input and invocation count.
23
23
@@ -27,7 +27,8 @@ def deterministic_failure(path, timing_map, i, *, name=None):
27
27
the sign indicates the input is returned normally (positive, or 0),
28
28
or an exception is raised (negative).
29
29
30
- If a input is missing then all invocations will run normally.
30
+ If a input is missing then all invocations will run normally, with a
31
+ small default sleep to avoid spurious backups being launched.
31
32
32
33
If there are subsequent invocations to the ones in the sequence, then
33
34
they will all run normally.
@@ -41,11 +42,11 @@ def deterministic_failure(path, timing_map, i, *, name=None):
41
42
invocation_count = 0
42
43
write_int_to_file (invocation_count_file , invocation_count + 1 )
43
44
44
- timing_code = 0
45
+ timing_code = default_sleep
45
46
if i in timing_map :
46
47
timing_codes = timing_map [i ]
47
48
if invocation_count >= len (timing_codes ):
48
- timing_code = 0
49
+ timing_code = default_sleep
49
50
else :
50
51
timing_code = timing_codes [invocation_count ]
51
52
0 commit comments