push
github
0 of 13 new or added lines in 2 files covered. (0.0%)
758 of 2287 relevant lines covered (33.14%)
1.15 hits per line
| 1 |
import logging |
2✔ |
| 2 |
import random |
2✔ |
| 3 |
import time |
2✔ |
| 4 |
|
|
| 5 |
import testit_api_client |
2✔ |
| 6 |
|
|
| 7 |
|
|
| 8 |
def retry(func): |
2✔ |
| 9 |
def retry_wrapper(*args, **kwargs): |
2✔ |
| 10 |
attempts = 0
|
× |
| 11 |
retries = 10
|
× |
| 12 |
|
|
| 13 |
while attempts < retries:
|
× |
| 14 |
try:
|
× |
| 15 |
return func(*args, **kwargs)
|
× |
| 16 |
except testit_api_client.exceptions.ApiException as e: |
× |
| 17 |
sleep_time = random.randrange(0, 100) |
× |
| 18 |
time.sleep(sleep_time/100)
|
× |
| 19 |
attempts += 1
|
× |
| 20 |
|
|
| 21 |
logging.error(e) |
× |
|
NEW
|
if e.status == '404': |
× |
|
NEW
|
attempts = retries |
× |
|
NEW
|
return
|
× |
|
NEW
|
if e.status == '400': |
× |
|
NEW
|
attempts = retries |
× |
|
NEW
|
return
|
× |
| 28 |
|
|
| 29 |
return retry_wrapper
|
2✔ |