Skip to content

Commit

Permalink
add time limit
Browse files Browse the repository at this point in the history
  • Loading branch information
BinamB committed Mar 3, 2025
1 parent 0b891b3 commit 1880f72
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion files/scripts/workspaces_launch_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,13 @@ def start_workspace_launch_test(self, image_name, workspace_id):
return json_result


def monitor_workspace_status(self, interval=10):
def monitor_workspace_status(self, interval=10, timeout_limit=10):
"""
In an interval of given time (in seconds) hit the workspace status endpoint to monitor the status of the workspace
Args:
interval (int, optional): Interval (in seconds) to hit the options endpoint. Defaults to 10 seconds.
timeout_limit(int, optional): Time limit at which a workspace launch is considered a failure.
"""
status_url = self.commons_url + "/lw-workspace/status"

Expand All @@ -207,6 +208,12 @@ def monitor_workspace_status(self, interval=10):
self.launch_status = "Not Found"
self.status_response = status_response.json()
break
elif time.time() - self.start_time >= timeout_limit * 60:
logging.error(f"Workspace failed to come up in {timeout_limit * 60} minutes")
self.launch_status = f"Workspace failed to come up in {timeout_limit * 60} minutes"
self.status_response = status_response.json()
break


time.sleep(interval)
logging.info(f"Elapsed time: {time.time()-self.start_time}")
Expand Down

0 comments on commit 1880f72

Please sign in to comment.