Skip to content

Commit

Permalink
Merge pull request #42 from geniusyield/40-improve-error-logging-on-s…
Browse files Browse the repository at this point in the history
…tartup

Improve error logging on startup
  • Loading branch information
4TT1L4 authored Apr 29, 2024
2 parents d2746d6 + f9bb304 commit 8643e6a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def worker():
time.sleep(STARTUP_DELAY)
while not attempt_successful:
try:
logger.info(f" > Connecting to backend...")
response: Response[ErrorResponse | Settings] = get_settings.sync_detailed(client=client)
settings_response: Response[Settings] = cast(Response[Settings], response)
if (settings := settings_response.parsed) is not None:
Expand All @@ -79,12 +80,13 @@ def worker():
else:
logger.info(f" > Could not parse response. Retry again...")
except Exception as e:
# If an exception occurs, print the message and wait for 5 seconds
# If an exception occurs, print the message and wait for the backend to start:
logger.info(f" > Exception: {str(e)}")
logger.info(f" > Backend is not available. Retry in {RETRY_DELAY} seconds...")
logger.debug(e)
time.sleep(RETRY_DELAY)
# The loop will then automatically retry

logger.info(f" > [OK] Succesfully connected to backend.")
api_client = Api(client, own_address, CONFIRMATION_DELAY, logger)
logger.info("==============================================")
logger.info("[OK] Initialization is done ✅ ")
Expand Down

0 comments on commit 8643e6a

Please sign in to comment.