diff --git a/actors/__init__.py b/actors/__init__.py index 05b32a5a..95e89832 100644 --- a/actors/__init__.py +++ b/actors/__init__.py @@ -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 @@ -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 \ No newline at end of file + 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) \ No newline at end of file