diff --git a/desktop_env/envs/desktop_env.py b/desktop_env/envs/desktop_env.py index b06abbb..e2f8376 100644 --- a/desktop_env/envs/desktop_env.py +++ b/desktop_env/envs/desktop_env.py @@ -53,19 +53,22 @@ class DesktopEnv(gym.Env): else: print("Starting VM...") _execute_command(["vmrun", "-T", "ws", "start", self.path_to_vm]) - time.sleep(10) + time.sleep(3) except subprocess.CalledProcessError as e: print(f"Error executing command: {e.output.decode().strip()}") def _get_vm_ip(self): - max_retries = 3 + max_retries = 10 + print("Getting IP Address...") for _ in range(max_retries): try: - output = _execute_command(["vmrun", "-T", "ws", "getGuestIPAddress", self.path_to_vm]) - return output.strip() + output = _execute_command(["vmrun", "-T", "ws", "getGuestIPAddress", self.path_to_vm]).strip() + print(f"IP address: {output}") + return output except: - time.sleep(2) + time.sleep(5) print("Retrying...") + raise Exception("Failed to get VM IP address!") def _save_state(self): _execute_command(["vmrun", "-T", "ws" "snapshot", self.path_to_vm, self.snapshot_path])