Skip to content

Commit 9c2fec8

Browse files
author
Takashi Matsuo
committed
add randomness to the sleep calls
1 parent 0a94813 commit 9c2fec8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

monitoring/api/v3/alerts-client/snippets_test.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
import snippets
2929

3030

31+
# We assume we have access to good randomness source.
32+
random.seed()
33+
34+
3135
def random_name(length):
3236
return ''.join(
3337
[random.choice(string.ascii_lowercase) for i in range(length)])
@@ -39,7 +43,8 @@ def retry_if_aborted(exception):
3943

4044
def delay_on_aborted(err, *args):
4145
if retry_if_aborted(err[1]):
42-
time.sleep(2)
46+
# add randomness for avoiding continuous conflict
47+
time.sleep(2 + (random.randint(0, 9) * 0.1))
4348
return True
4449
return False
4550

0 commit comments

Comments
 (0)