Skip to content

Commit

Permalink
Harden t init as network can break startup
Browse files Browse the repository at this point in the history
  • Loading branch information
NotChristianGarcia committed Jan 3, 2024
1 parent c0bbfe1 commit 76eb05e
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions service/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,16 @@
logger = get_logger(__name__)

Tenants = TenantCache()
try:
t = get_service_tapis_client(tenants=Tenants)
except Exception as e:
logger.error(f'Could not instantiate tapy service client. Exception: {e}')
raise e

# Create Tapis `t` client
for _ in range(10):
try:
t = get_service_tapis_client(tenants=Tenants)
break # Exit the loop if t is successfully created
except Exception as e:
logger.error(f'Could not instantiate tapy service client. Exception: {e}')
time.sleep(2) # Delay for 2 seconds before the next attempt
else:
msg = 'Failed to create tapy service client after 10 attempts (20 seconds), networking?'
logger.error(msg)
raise RuntimeError(msg)

0 comments on commit 76eb05e

Please sign in to comment.