From ba583c4ce8f0cd9b541744710e4714d8944537da Mon Sep 17 00:00:00 2001 From: Stanislaw Malinowski Date: Wed, 3 Apr 2024 15:22:44 +0100 Subject: [PATCH] change timeout in the cli --- src/blueapi/cli/cli.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/blueapi/cli/cli.py b/src/blueapi/cli/cli.py index 27bbc6e7d..17827f869 100644 --- a/src/blueapi/cli/cli.py +++ b/src/blueapi/cli/cli.py @@ -286,9 +286,10 @@ def env(obj: dict, reload: Optional[bool]) -> None: # Initialize a variable to keep track of the environment status environment_initialized = False - + polling_count = 0 + max_polling_count = 10 # Use a while loop to keep checking until the environment is initialized - while not environment_initialized: + while (not environment_initialized and polling_count < max_polling_count): # Fetch the current environment status environment_status = client.get_environment() @@ -298,7 +299,10 @@ def env(obj: dict, reload: Optional[bool]) -> None: environment_initialized = True else: print("Waiting for environment to initialize...") - sleep(5) # Wait for 5 seconds before checking again + polling_count += 1 + sleep(1) # Wait for 1 seconds before checking again + if(polling_count == max_polling_count): + raise TimeoutError("Environment initialization timed out.") # Once out of the loop, print the initialized environment status pprint(environment_status)