Skip to content

Commit

Permalink
Harden t init as networking issues can slow or break the ability to…
Browse files Browse the repository at this point in the history
… initialize said `t`.
  • Loading branch information
NotChristianGarcia committed Dec 2, 2023
1 parent c164033 commit 94e307c
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions actors/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import time

# Initialize as normal if this module is NOT called from a test container.
# This allows us to not use flaskbase when calling codes.py
Expand All @@ -11,8 +12,14 @@
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
for _ in range(5):
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, networking?'
logger.error(msg)
raise RuntimeError(msg)

0 comments on commit 94e307c

Please sign in to comment.