@@ -43,6 +43,14 @@ def __enter__(self) -> "MatchManager":
4343 def __exit__ (self , exc_type , exc_val , exc_tb ) -> None :
4444 self .disconnect ()
4545
46+ @property
47+ def _rlbot_server_name (self ) -> str :
48+ return (
49+ self .rlbot_server_path .stem
50+ if self .rlbot_server_path is not None and self .rlbot_server_path .is_file ()
51+ else RLBOT_SERVER_NAME
52+ )
53+
4654 def ensure_server_started (self ):
4755 """
4856 Ensures that RLBotServer is running, starting it if it is not.
@@ -51,11 +59,7 @@ def ensure_server_started(self):
5159 otherwise the global installed RLBotServer will be used, if any.
5260 """
5361
54- exe_name = (
55- self .rlbot_server_path .stem
56- if self .rlbot_server_path is not None and self .rlbot_server_path .is_file ()
57- else RLBOT_SERVER_NAME
58- )
62+ exe_name = self ._rlbot_server_name
5963 self .rlbot_server_process , self .rlbot_server_port = gateway .find_server_process (
6064 exe_name
6165 )
@@ -259,7 +263,7 @@ def shut_down(self, use_force_if_necessary: bool = True):
259263 # In theory this is all we need for the server to cleanly shut itself down
260264 self .rlbot_interface .stop_match (shutdown_server = True )
261265 except BrokenPipeError :
262- match gateway .find_server_process (self .main_executable_name )[0 ]:
266+ match gateway .find_server_process (self ._rlbot_server_name )[0 ]:
263267 case psutil .Process () as proc :
264268 self .logger .warning (
265269 "Can't communicate with RLBotServer, ensuring shutdown."
@@ -281,12 +285,12 @@ def shut_down(self, use_force_if_necessary: bool = True):
281285 sleep (1 )
282286
283287 self .rlbot_server_process , _ = gateway .find_server_process (
284- self .main_executable_name
288+ self ._rlbot_server_name
285289 )
286290
287291 if self .rlbot_server_process is not None :
288292 self .logger .info (
289- "Waiting for %s to shut down..." , self .main_executable_name
293+ "Waiting for %s to shut down..." , self ._rlbot_server_name
290294 )
291295
292296 if use_force_if_necessary :
@@ -295,13 +299,13 @@ def shut_down(self, use_force_if_necessary: bool = True):
295299 elif sleeps == 4 or sleeps == 7 :
296300 self .logger .warning (
297301 "%s is not responding to terminate requests." ,
298- self .main_executable_name ,
302+ self ._rlbot_server_name ,
299303 )
300304 self .rlbot_server_process .terminate ()
301305 elif sleeps >= 10 and sleeps % 3 == 1 :
302306 self .logger .error (
303307 "%s is not responding, forcefully killing." ,
304- self .main_executable_name ,
308+ self ._rlbot_server_name ,
305309 )
306310 self .rlbot_server_process .kill ()
307311
0 commit comments