|
12 | 12 |
|
13 | 13 | class ThreeScaleClient: |
14 | 14 | def __init__(self, url: str, token: str, |
15 | | - throws: bool = True, ssl_verify: bool = True, wait: bool = False): |
| 15 | + throws: bool = True, ssl_verify: bool = True, wait: int = -1): |
16 | 16 | """Creates instance of the 3scale client |
17 | 17 | Args: |
18 | 18 | url: 3scale instance url |
19 | 19 | token: Access token |
20 | 20 | throws: Whether it should throw an error |
21 | 21 | ssl_verify: Whether to verify ssl |
22 | | - wait: Whether to do extra checks of 3scale availability |
| 22 | + wait: Whether to wait for 3scale availability, negative number == no waiting |
| 23 | + positive number == wait another extra seconds |
23 | 24 | """ |
24 | 25 | self._rest = RestApiClient(url=url, token=token, throws=throws, ssl_verify=ssl_verify) |
25 | 26 | self._services = resources.Services(self, instance_klass=resources.Service) |
@@ -50,12 +51,12 @@ def __init__(self, url: str, token: str, |
50 | 51 | self._fields_definitions =\ |
51 | 52 | resources.FieldsDefinitions(self, instance_klass=resources.FieldsDefinition) |
52 | 53 |
|
53 | | - if wait: |
| 54 | + if wait >= 0: |
54 | 55 | self.wait_for_tenant() |
55 | 56 | # TODO: all the implemented checks aren't enough yet |
56 | 57 | # 3scale can still return 404/409 error, therefore slight artificial sleep |
57 | 58 | # here to mitigate the problem. This requires proper fix in checks |
58 | | - time.sleep(16) |
| 59 | + time.sleep(wait) |
59 | 60 |
|
60 | 61 | @backoff.on_predicate(backoff.fibo, lambda ready: not ready, max_tries=8, jitter=None) |
61 | 62 | def wait_for_tenant(self) -> bool: |
|
0 commit comments