blob: 04895b0e70cf934b2e1a5c56894fac533260f782 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
"""
It would be great to find the real underlying issue here, but without these
retries we get annoying flakey test errors. So it's preferable to hack this
fix to actually guarantee it doesn't generate false negatives in the test
suite.
"""
import os
import concurrent
RETRIES = 3
def retry_stalled_init_fix_hack():
if "DISABLE_TIMEOUT" in os.environ:
return lambda f: f
def decorator(func):
def newfn(*args, **kwargs):
attempt = 0
while attempt < RETRIES:
try:
return func(*args, **kwargs)
except concurrent.futures._base.TimeoutError:
print(
"\n\nRetrying timeouted test server init "
"%d of %d\n" % (attempt, RETRIES)
)
attempt += 1
return func(*args, **kwargs)
return newfn
return decorator
|