@@ -58,13 +58,13 @@ def __init__(self, settings):
58
58
self .settings = settings
59
59
self .processes = {"matlab" : None , "xvfb" : None }
60
60
61
- # Timeout for processes launched by matlab-proxy
61
+ # Timeout for processes started by matlab-proxy
62
62
self .PROCESS_TIMEOUT = get_process_startup_timeout ()
63
63
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.
65
65
self .matlab_port = None
66
66
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.
68
68
self .mwi_logs_dir = None
69
69
70
70
# Dictionary of all files used to manage the MATLAB session.
@@ -99,7 +99,7 @@ def __init__(self, settings):
99
99
self .embedded_connector_start_time = None
100
100
101
101
# 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),
103
103
# the state of MATLAB process in app_state will continue to be in a 'starting' indefinitely.
104
104
# This variable can be either "up" or "down"
105
105
self .embedded_connector_state = "down"
@@ -222,15 +222,15 @@ def __get_cached_config_file(self):
222
222
def __delete_cached_config_file (self ):
223
223
"""Deletes the cached config file"""
224
224
try :
225
- logger .info (f"Deleting any cached config files!" )
225
+ logger .debug (f"Deleting any cached config files!" )
226
226
os .remove (self .__get_cached_config_file ())
227
227
except FileNotFoundError :
228
228
# The file being absent is acceptable.
229
229
pass
230
230
231
231
def __reset_and_delete_cached_config (self ):
232
232
"""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..." )
234
234
self .licensing = None
235
235
self .__delete_cached_config_file ()
236
236
@@ -259,14 +259,14 @@ async def init_licensing(self):
259
259
# Default value
260
260
self .licensing = None
261
261
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
263
263
if self .settings ["mwi_use_existing_license" ]:
264
264
self .licensing = {"type" : "existing_license" }
265
265
logger .debug (
266
266
f"{ mwi_env .get_env_name_mwi_use_existing_license ()} variable set in environment"
267
267
)
268
268
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 !!!"
270
270
)
271
271
272
272
# 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):
276
276
elif self .settings .get ("nlm_conn_str" , None ) is not None :
277
277
nlm_licensing_str = self .settings .get ("nlm_conn_str" )
278
278
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..." )
280
280
self .licensing = {
281
281
"type" : "nlm" ,
282
282
"conn_str" : nlm_licensing_str ,
@@ -307,7 +307,7 @@ async def init_licensing(self):
307
307
"type" : "nlm" ,
308
308
"conn_str" : licensing ["conn_str" ],
309
309
}
310
- logger .info ("Using cached NLM licensing to launch MATLAB" )
310
+ logger .debug ("Using cached NLM licensing to start MATLAB" )
311
311
312
312
elif licensing ["type" ] == "mhlm" :
313
313
self .licensing = {
@@ -335,12 +335,12 @@ async def init_licensing(self):
335
335
)
336
336
if successful_update :
337
337
logger .debug (
338
- "Using cached Online Licensing to launch MATLAB."
338
+ "Using cached Online Licensing to start MATLAB."
339
339
)
340
340
else :
341
341
self .__reset_and_delete_cached_config ()
342
342
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" )
344
344
self .licensing = licensing
345
345
else :
346
346
# Somethings wrong, licensing is neither NLM or MHLM
@@ -920,14 +920,14 @@ def clean_up_mwi_server_session(self):
920
920
try :
921
921
for session_file in self .mwi_server_session_files .items ():
922
922
if session_file [1 ] is not None :
923
- logger .info (f"Deleting:{ session_file [1 ]} " )
923
+ logger .debug (f"Deleting:{ session_file [1 ]} " )
924
924
session_file [1 ].unlink ()
925
925
except FileNotFoundError :
926
926
# Files may not exist if cleanup is called before they are created
927
927
pass
928
928
929
929
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.
931
931
932
932
Returns:
933
933
[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:
979
979
if system .is_linux ():
980
980
if self .settings .get ("matlab_display" , None ):
981
981
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"
984
984
)
985
985
else :
986
986
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"
989
989
)
990
990
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."
993
993
)
994
994
995
995
# 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):
1080
1080
1081
1081
return xvfb
1082
1082
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
1084
1084
# and for showing the error on the frontend.
1085
1085
1086
1086
# 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.
1088
1088
except (FileNotFoundError , XvfbError ) as err :
1089
1089
self .error = XvfbError (
1090
1090
"""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):
1178
1178
else :
1179
1179
time_diff = time .time () - self .embedded_connector_start_time
1180
1180
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 .
1182
1182
# Set the error and stop matlab.
1183
1183
user_visible_error = "Unable to start MATLAB.\n Try again by clicking Start MATLAB."
1184
1184
@@ -1187,32 +1187,27 @@ async def __track_embedded_connector_state(self):
1187
1187
# So, raise a generic error wherever appropriate
1188
1188
generic_error = f"MATLAB did not start in { int (self .PROCESS_TIMEOUT )} seconds. Use Windows Remote Desktop to check for any errors."
1189
1189
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
1202
1196
1203
1197
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 .
1205
1199
# Set the error and stop matlab.
1206
1200
logger .error (
1207
1201
f":{ this_task } : MATLAB did not start in { int (self .PROCESS_TIMEOUT )} seconds!"
1208
1202
)
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
1216
1211
1217
1212
else :
1218
1213
logger .debug (
@@ -1410,7 +1405,7 @@ async def stop_matlab(self, force_quit=False):
1410
1405
if session_file_path is not None :
1411
1406
self .matlab_session_files [session_file_name ] = None
1412
1407
with contextlib .suppress (FileNotFoundError ):
1413
- logger .info (f"Deleting:{ session_file_path } " )
1408
+ logger .debug (f"Deleting:{ session_file_path } " )
1414
1409
session_file_path .unlink ()
1415
1410
1416
1411
# In posix systems, variable matlab is an instance of asyncio.subprocess.Process()
@@ -1496,7 +1491,7 @@ async def stop_matlab(self, force_quit=False):
1496
1491
if system .is_posix ():
1497
1492
xvfb = self .processes ["xvfb" ]
1498
1493
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 } )" )
1500
1495
xvfb .terminate ()
1501
1496
waiters .append (xvfb .wait ())
1502
1497
0 commit comments