@@ -628,6 +628,20 @@ async def __setup_env_for_matlab(self) -> dict:
628628
629629 return matlab_env
630630
631+ def __filter_env_variables (env_vars : dict [str , str ], prefix : str ) -> dict [str , str ]:
632+ """Removes the keys that starts with the prefix supplied to this function
633+
634+ Args:
635+ env_vars (dict[str, str]): dict to be filtered
636+ prefix (str): starting characters of the keys to be removed
637+
638+ Returns:
639+ dict[str, str]: dict with filtered keys
640+ """
641+ return {
642+ key : value for key , value in env_vars .items () if not key .startswith (prefix )
643+ }
644+
631645 async def __start_xvfb_process (self ):
632646 """Private method to start the xvfb process. Will set appropriate
633647 errors to self.error and return None when any exceptions are raised.
@@ -639,9 +653,14 @@ async def __start_xvfb_process(self):
639653 # Start Xvfb process and update display number in settings
640654 create_xvfb_cmd = self .settings ["create_xvfb_cmd" ]
641655 xvfb_cmd , dpipe = create_xvfb_cmd ()
656+ filtered_env_variables = AppState .__filter_env_variables (
657+ os .environ .copy (), "MWI_"
658+ )
642659
643660 try :
644- xvfb , display_port = await mw .create_xvfb_process (xvfb_cmd , dpipe )
661+ xvfb , display_port = await mw .create_xvfb_process (
662+ xvfb_cmd , dpipe , filtered_env_variables
663+ )
645664 self .settings ["matlab_display" ] = ":" + str (display_port )
646665
647666 logger .debug (f"Started Xvfb with PID={ xvfb .pid } on DISPLAY={ display_port } " )
0 commit comments