Skip to content

Commit

Permalink
Up retry time
Browse files Browse the repository at this point in the history
  • Loading branch information
emnigma committed Aug 8, 2023
1 parent eefc438 commit 8a6b842
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
9 changes: 4 additions & 5 deletions VSharp.ML.AIAgent/connection/broker_conn/socket_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,18 @@
def wait_for_connection(url: WSUrl):
ws = websocket.WebSocket()

max_retries = 60
retries_left = 60
retries_left = GameServerConnectorConfig.WAIT_FOR_SOCKET_RECONNECTION_MAX_RETRIES

while retries_left:
with suppress(ConnectionRefusedError, ConnectionResetError):
ws.settimeout(GameServerConnectorConfig.CREATE_CONNECTION_TIMEOUT)
ws.settimeout(GameServerConnectorConfig.CREATE_CONNECTION_TIMEOUT_SEC)
ws.connect(
url, skip_utf8_validation=GameServerConnectorConfig.SKIP_UTF_VALIDATION
)
if ws.connected:
return ws
time.sleep(GameServerConnectorConfig.CREATE_CONNECTION_TIMEOUT)
logging.info(f"Try connecting, did {max_retries - retries_left} attempts")
time.sleep(GameServerConnectorConfig.CREATE_CONNECTION_TIMEOUT_SEC)
logging.info(f"Try connecting, {retries_left} attempts left")
retries_left -= 1
raise RuntimeError("Retries exsausted")

Expand Down
8 changes: 5 additions & 3 deletions VSharp.ML.AIAgent/launch_servers.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,12 @@ async def enqueue_instance(request):
)
logging.info(f"got {returned_instance_info} from client")

if FeatureConfig.ON_GAME_SERVER_RESTART:
if FeatureConfig.ON_GAME_SERVER_RESTART.enabled:
kill_server(returned_instance_info.pid, forget=True)

wait_for_reset_retries = 600
wait_for_reset_retries = (
FeatureConfig.ON_GAME_SERVER_RESTART.wait_for_reset_retries
)
while wait_for_reset_retries:
logging.info(
f"Waiting for server to die, {wait_for_reset_retries} retries left"
Expand All @@ -62,7 +64,7 @@ async def enqueue_instance(request):
!= psutil.STATUS_RUNNING
):
break
time.sleep(0.1)
time.sleep(FeatureConfig.ON_GAME_SERVER_RESTART.wait_for_reset_time)
wait_for_reset_retries -= 1

if wait_for_reset_retries == 0:
Expand Down

0 comments on commit 8a6b842

Please sign in to comment.