add longer retries

This commit is contained in:
Jing Hua
2023-12-03 17:24:44 +08:00
parent 58e9807a70
commit b10908b4fa

View File

@@ -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])