@@ -58,13 +58,13 @@ def __init__(self, settings):
5858 self .settings = settings
5959 self .processes = {"matlab" : None , "xvfb" : None }
6060
61- # Timeout for processes launched by matlab-proxy
61+ # Timeout for processes started by matlab-proxy
6262 self .PROCESS_TIMEOUT = get_process_startup_timeout ()
6363
64- # The port on which MATLAB(launched by this matlab-proxy process) starts on.
64+ # The port on which MATLAB(started by this matlab-proxy process) starts on.
6565 self .matlab_port = None
6666
67- # The directory in which the instance of MATLAB (launched by this matlab-proxy process) will write logs to.
67+ # The directory in which the instance of MATLAB (started by this matlab-proxy process) will write logs to.
6868 self .mwi_logs_dir = None
6969
7070 # Dictionary of all files used to manage the MATLAB session.
@@ -99,7 +99,7 @@ def __init__(self, settings):
9999 self .embedded_connector_start_time = None
100100
101101 # Keep track of the state of the Embedded Connector.
102- # If there is some problem with launching the Embedded Connector(say an issue with licensing),
102+ # If there is some problem with starting the Embedded Connector(say an issue with licensing),
103103 # the state of MATLAB process in app_state will continue to be in a 'starting' indefinitely.
104104 # This variable can be either "up" or "down"
105105 self .embedded_connector_state = "down"
@@ -222,15 +222,15 @@ def __get_cached_config_file(self):
222222 def __delete_cached_config_file (self ):
223223 """Deletes the cached config file"""
224224 try :
225- logger .info (f"Deleting any cached config files!" )
225+ logger .debug (f"Deleting any cached config files!" )
226226 os .remove (self .__get_cached_config_file ())
227227 except FileNotFoundError :
228228 # The file being absent is acceptable.
229229 pass
230230
231231 def __reset_and_delete_cached_config (self ):
232232 """Reset licensing variable of the class and removes the cached config file."""
233- logger .info (f"Resetting cached config information..." )
233+ logger .debug (f"Resetting cached config information..." )
234234 self .licensing = None
235235 self .__delete_cached_config_file ()
236236
@@ -259,14 +259,14 @@ async def init_licensing(self):
259259 # Default value
260260 self .licensing = None
261261
262- # If MWI_USE_EXISTING_LICENSE is set in environment, try launching MATLAB directly
262+ # If MWI_USE_EXISTING_LICENSE is set in environment, try starting MATLAB directly
263263 if self .settings ["mwi_use_existing_license" ]:
264264 self .licensing = {"type" : "existing_license" }
265265 logger .debug (
266266 f"{ mwi_env .get_env_name_mwi_use_existing_license ()} variable set in environment"
267267 )
268268 logger .info (
269- f"!!! Launching MATLAB without providing any additional licensing information. This requires MATLAB to have been activated on the machine from which its being launched !!!"
269+ f"!!! Starting MATLAB without providing any additional licensing information. This requires MATLAB to have been activated on the machine from which its being started !!!"
270270 )
271271
272272 # Delete old config info from cache to ensure its wiped out first before persisting new info.
@@ -276,7 +276,7 @@ async def init_licensing(self):
276276 elif self .settings .get ("nlm_conn_str" , None ) is not None :
277277 nlm_licensing_str = self .settings .get ("nlm_conn_str" )
278278 logger .debug (f"Found NLM:[{ nlm_licensing_str } ] set in environment" )
279- logger .debug (f"Using NLM string to connect ... " )
279+ logger .info (f"Using NLM: { nlm_licensing_str } to connect..." )
280280 self .licensing = {
281281 "type" : "nlm" ,
282282 "conn_str" : nlm_licensing_str ,
@@ -307,7 +307,7 @@ async def init_licensing(self):
307307 "type" : "nlm" ,
308308 "conn_str" : licensing ["conn_str" ],
309309 }
310- logger .info ("Using cached NLM licensing to launch MATLAB" )
310+ logger .debug ("Using cached NLM licensing to start MATLAB" )
311311
312312 elif licensing ["type" ] == "mhlm" :
313313 self .licensing = {
@@ -335,12 +335,12 @@ async def init_licensing(self):
335335 )
336336 if successful_update :
337337 logger .debug (
338- "Using cached Online Licensing to launch MATLAB."
338+ "Using cached Online Licensing to start MATLAB."
339339 )
340340 else :
341341 self .__reset_and_delete_cached_config ()
342342 elif licensing ["type" ] == "existing_license" :
343- logger .info ("Using cached existing license to launch MATLAB" )
343+ logger .debug ("Using cached existing license to start MATLAB" )
344344 self .licensing = licensing
345345 else :
346346 # Somethings wrong, licensing is neither NLM or MHLM
@@ -920,14 +920,14 @@ def clean_up_mwi_server_session(self):
920920 try :
921921 for session_file in self .mwi_server_session_files .items ():
922922 if session_file [1 ] is not None :
923- logger .info (f"Deleting:{ session_file [1 ]} " )
923+ logger .debug (f"Deleting:{ session_file [1 ]} " )
924924 session_file [1 ].unlink ()
925925 except FileNotFoundError :
926926 # Files may not exist if cleanup is called before they are created
927927 pass
928928
929929 async def __setup_env_for_matlab (self ) -> dict :
930- """Configure the environment variables required for launching MATLAB by matlab-proxy.
930+ """Configure the environment variables required for starting MATLAB by matlab-proxy.
931931
932932 Returns:
933933 [dict]: Containing keys as the Env variable names and values are its corresponding values.
@@ -979,17 +979,17 @@ async def __setup_env_for_matlab(self) -> dict:
979979 if system .is_linux ():
980980 if self .settings .get ("matlab_display" , None ):
981981 matlab_env ["DISPLAY" ] = self .settings ["matlab_display" ]
982- logger .info (
983- f"Using the display number supplied by Xvfb process'{ matlab_env ['DISPLAY' ]} ' for launching MATLAB"
982+ logger .debug (
983+ f"Using the display number supplied by Xvfb process'{ matlab_env ['DISPLAY' ]} ' for starting MATLAB"
984984 )
985985 else :
986986 if "DISPLAY" in matlab_env :
987- logger .info (
988- f"Using the existing DISPLAY environment variable with value:{ matlab_env ['DISPLAY' ]} for launching MATLAB"
987+ logger .debug (
988+ f"Using the existing DISPLAY environment variable with value:{ matlab_env ['DISPLAY' ]} for starting MATLAB"
989989 )
990990 else :
991- logger .info (
992- "No DISPLAY environment variable found. Launching MATLAB without it."
991+ logger .debug (
992+ "No DISPLAY environment variable found. Starting MATLAB without it."
993993 )
994994
995995 # The matlab ready file is written into this location(self.mwi_logs_dir) by MATLAB
@@ -1080,11 +1080,11 @@ async def __start_xvfb_process(self):
10801080
10811081 return xvfb
10821082
1083- # If something went wrong ie. exception is raised in launching Xvfb process, capture error for logging
1083+ # If something went wrong ie. exception is raised in starting Xvfb process, capture error for logging
10841084 # and for showing the error on the frontend.
10851085
10861086 # FileNotFoundError: is thrown if Xvfb is not found on System Path.
1087- # XvfbError: is thrown if something went wrong when launching Xvfb process.
1087+ # XvfbError: is thrown if something went wrong when starting Xvfb process.
10881088 except (FileNotFoundError , XvfbError ) as err :
10891089 self .error = XvfbError (
10901090 """Unable to start the Xvfb process. Ensure Xvfb is installed and is available on the System Path. See https://github.com/mathworks/matlab-proxy#requirements for information on Xvfb"""
@@ -1178,7 +1178,7 @@ async def __track_embedded_connector_state(self):
11781178 else :
11791179 time_diff = time .time () - self .embedded_connector_start_time
11801180 if time_diff > self .PROCESS_TIMEOUT :
1181- # Since max allowed startup time has elapsed, it means that MATLAB is in a stuck state and cannot be launched .
1181+ # Since max allowed startup time has elapsed, it means that MATLAB is stuck and is unable to start .
11821182 # Set the error and stop matlab.
11831183 user_visible_error = "Unable to start MATLAB.\n Try again by clicking Start MATLAB."
11841184
@@ -1187,32 +1187,27 @@ async def __track_embedded_connector_state(self):
11871187 # So, raise a generic error wherever appropriate
11881188 generic_error = f"MATLAB did not start in { int (self .PROCESS_TIMEOUT )} seconds. Use Windows Remote Desktop to check for any errors."
11891189 logger .error (f":{ this_task } : { generic_error } " )
1190- if len (self .logs ["matlab" ]) == 0 :
1191- await self .__force_stop_matlab (
1192- user_visible_error , this_task
1193- )
1194- # Breaking out of the loop to end this task as matlab-proxy was unable to launch MATLAB successfully
1195- # even after waiting for self.PROCESS_TIMEOUT
1196- break
1197- else :
1198- # Do not stop the MATLAB process or break from the loop (the error type is unknown)
1199- self .error = MatlabError (generic_error )
1200- await asyncio .sleep (5 )
1201- continue
1190+
1191+ # Stopping the MATLAB process would remove the UI window displaying the error too.
1192+ # Do not stop the MATLAB or break from the loop (as the error is still unknown)
1193+ self .error = MatlabError (generic_error )
1194+ await asyncio .sleep (5 )
1195+ continue
12021196
12031197 else :
1204- # If there are no logs after the max startup time has elapsed, it means that MATLAB is in a stuck state and cannot be launched .
1198+ # If there are no logs after the max startup time has elapsed, it means that MATLAB is stuck and is unable to start .
12051199 # Set the error and stop matlab.
12061200 logger .error (
12071201 f":{ this_task } : MATLAB did not start in { int (self .PROCESS_TIMEOUT )} seconds!"
12081202 )
1209- if len (self .logs ["matlab" ]) == 0 :
1210- await self .__force_stop_matlab (
1211- user_visible_error , this_task
1212- )
1213- # Breaking out of the loop to end this task as matlab-proxy was unable to launch MATLAB successfully
1214- # even after waiting for self.PROCESS_TIMEOUT
1215- break
1203+ # MATLAB can be stopped on posix systems because the stderr pipe of the MATLAB process is
1204+ # read (by __matlab_stderr_reader_posix() task) and is logged by matlab-proxy appropriately.
1205+ await self .__force_stop_matlab (
1206+ user_visible_error , this_task
1207+ )
1208+ # Breaking out of the loop to end this task as matlab-proxy was unable to start MATLAB successfully
1209+ # even after waiting for self.PROCESS_TIMEOUT
1210+ break
12161211
12171212 else :
12181213 logger .debug (
@@ -1410,7 +1405,7 @@ async def stop_matlab(self, force_quit=False):
14101405 if session_file_path is not None :
14111406 self .matlab_session_files [session_file_name ] = None
14121407 with contextlib .suppress (FileNotFoundError ):
1413- logger .info (f"Deleting:{ session_file_path } " )
1408+ logger .debug (f"Deleting:{ session_file_path } " )
14141409 session_file_path .unlink ()
14151410
14161411 # In posix systems, variable matlab is an instance of asyncio.subprocess.Process()
@@ -1496,7 +1491,7 @@ async def stop_matlab(self, force_quit=False):
14961491 if system .is_posix ():
14971492 xvfb = self .processes ["xvfb" ]
14981493 if xvfb is not None and xvfb .returncode is None :
1499- logger .info (f"Terminating Xvfb (PID={ xvfb .pid } )" )
1494+ logger .debug (f"Terminating Xvfb (PID={ xvfb .pid } )" )
15001495 xvfb .terminate ()
15011496 waiters .append (xvfb .wait ())
15021497
0 commit comments