Skip to content

Commit 2754edc

Browse files
authored
startup error check (#255)
Co-authored-by: Saimon Michelson <saimon.michelson@gmail.com>
1 parent 9b698bb commit 2754edc

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

cterasdk/core/startup.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,7 @@ def status(self):
1616
"""
1717
Get the server startup status
1818
"""
19-
response = None
20-
try:
21-
response = self._core.ctera.get('/startup')
22-
except ClientResponseException as error:
23-
return error.response.body.status
19+
response = self._core.ctera.get('/startup')
2420
return response.status
2521

2622
def wait(self, retries=120, seconds=5):
@@ -30,17 +26,17 @@ def wait(self, retries=120, seconds=5):
3026
attempt = 0
3127
while True:
3228
try:
29+
if attempt >= retries:
30+
logging.getLogger('cterasdk.core').error('Timed out. Server did not start in a timely manner.')
31+
raise CTERAException('Timed out. Server did not start in a timely manner')
3332
current_status = self.status()
3433
if current_status == Startup.Started:
3534
logging.getLogger('cterasdk.core').info('Server started.')
3635
break
3736
logging.getLogger('cterasdk.core').debug('Current server status. %s', {'status': current_status})
3837
attempt = attempt + 1
39-
if attempt >= retries:
40-
logging.getLogger('cterasdk.core').error('Timed out. Server did not start in a timely manner.')
41-
raise CTERAException('Timed out. Server did not start in a timely manner')
4238
time.sleep(seconds)
43-
except (ConnectionError, TimeoutError) as e:
39+
except (ConnectionError, TimeoutError, ClientResponseException) as e:
4440
logging.getLogger('cterasdk.core').debug('Exception. %s', e.__dict__)
4541
attempt = attempt + 1
4642
time.sleep(seconds)

0 commit comments

Comments
 (0)