Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions rlbot/managers/match.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ def __enter__(self) -> "MatchManager":
def __exit__(self, exc_type, exc_val, exc_tb) -> None:
self.disconnect()

@property
def _rlbot_server_name(self) -> str:
return (
self.rlbot_server_path.stem
if self.rlbot_server_path is not None and self.rlbot_server_path.is_file()
else RLBOT_SERVER_NAME
)

def ensure_server_started(self):
"""
Ensures that RLBotServer is running, starting it if it is not.
Expand All @@ -51,11 +59,7 @@ def ensure_server_started(self):
otherwise the global installed RLBotServer will be used, if any.
"""

exe_name = (
self.rlbot_server_path.stem
if self.rlbot_server_path is not None and self.rlbot_server_path.is_file()
else RLBOT_SERVER_NAME
)
exe_name = self._rlbot_server_name
self.rlbot_server_process, self.rlbot_server_port = gateway.find_server_process(
exe_name
)
Expand Down Expand Up @@ -259,7 +263,7 @@ def shut_down(self, use_force_if_necessary: bool = True):
# In theory this is all we need for the server to cleanly shut itself down
self.rlbot_interface.stop_match(shutdown_server=True)
except BrokenPipeError:
match gateway.find_server_process(self.main_executable_name)[0]:
match gateway.find_server_process(self._rlbot_server_name)[0]:
case psutil.Process() as proc:
self.logger.warning(
"Can't communicate with RLBotServer, ensuring shutdown."
Expand All @@ -281,12 +285,12 @@ def shut_down(self, use_force_if_necessary: bool = True):
sleep(1)

self.rlbot_server_process, _ = gateway.find_server_process(
self.main_executable_name
self._rlbot_server_name
)

if self.rlbot_server_process is not None:
self.logger.info(
"Waiting for %s to shut down...", self.main_executable_name
"Waiting for %s to shut down...", self._rlbot_server_name
)

if use_force_if_necessary:
Expand All @@ -295,13 +299,13 @@ def shut_down(self, use_force_if_necessary: bool = True):
elif sleeps == 4 or sleeps == 7:
self.logger.warning(
"%s is not responding to terminate requests.",
self.main_executable_name,
self._rlbot_server_name,
)
self.rlbot_server_process.terminate()
elif sleeps >= 10 and sleeps % 3 == 1:
self.logger.error(
"%s is not responding, forcefully killing.",
self.main_executable_name,
self._rlbot_server_name,
)
self.rlbot_server_process.kill()

Expand Down
2 changes: 1 addition & 1 deletion rlbot/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "2.0.0-beta.52"
__version__ = "2.0.0-beta.53"