Conditions | 4 |
Total Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 4 |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | """API client functions.""" |
||
15 | 1 | def get(url, data): |
|
16 | 1 | log.info("Getting %s: %s", url, data) |
|
17 | |||
18 | 1 | response = cache.get((url, data)) |
|
19 | 1 | if response is None: |
|
20 | 1 | for i in range(3): |
|
21 | 1 | response = requests.put(url, data=data) |
|
22 | 1 | if response.status_code == 500: |
|
23 | 1 | time.sleep(i + 1) |
|
24 | 1 | continue |
|
25 | else: |
||
26 | 1 | break |
|
27 | 1 | cache.set((url, data), response) |
|
28 | |||
29 | 1 | log.info("Response: %s", response) |
|
30 | |||
31 | 1 | return response |
|
32 | |||
48 |