forked from VSharp-team/VSharp
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
523 additions
and
293 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 28 additions & 5 deletions
33
VSharp.ML.AIAgent/connection/broker_conn/socket_manager.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,38 @@ | ||
from contextlib import contextmanager | ||
import time | ||
from contextlib import contextmanager, suppress | ||
|
||
import websocket | ||
from .requests import aquire_ws, return_ws | ||
|
||
from config import GameServerConnectorConfig | ||
from connection.broker_conn.classes import WSUrl | ||
|
||
from .requests import acquire_instance, return_instance | ||
|
||
websocket.setdefaulttimeout(GameServerConnectorConfig.RESPONCE_TIMEOUT_SEC) | ||
|
||
|
||
def wait_for_connection(url: WSUrl): | ||
ws = websocket.WebSocket() | ||
|
||
while True: | ||
with suppress(ConnectionRefusedError, ConnectionResetError): | ||
ws.settimeout(GameServerConnectorConfig.CREATE_CONNECTION_TIMEOUT) | ||
ws.connect( | ||
url, skip_utf8_validation=GameServerConnectorConfig.SKIP_UTF_VALIDATION | ||
) | ||
if ws.connected: | ||
return ws | ||
time.sleep(GameServerConnectorConfig.CREATE_CONNECTION_TIMEOUT) | ||
|
||
|
||
@contextmanager | ||
def game_server_socket_manager(): | ||
socket_url = aquire_ws() | ||
socket = websocket.create_connection(socket_url, skip_utf8_validation=True) | ||
server_instance = acquire_instance() | ||
|
||
socket = None | ||
try: | ||
socket = wait_for_connection(server_instance.ws_url) | ||
yield socket | ||
finally: | ||
socket.close() | ||
return_ws(socket_url) | ||
return_instance(server_instance) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
conda install numpy pandas tabulate | ||
conda install -c pytorch pytorch=1.13.1 torchvision=0.14.1 torchaudio=0.13.1 | ||
python3 -m pip install --force-reinstall -v "torch-scatter==2.1.0" "torch-geometric==2.2.0" "torch-sparse==0.6.16" | ||
python3 -m pip install func_timeout | ||
conda install -c conda-forge dataclasses-json websocket-client pre_commit aiohttp cchardet pygad httplib2 onnx onnxruntime | ||
pre-commit install |
Oops, something went wrong.