@@ -13788,31 +13788,33 @@ def __activate_virtual_display_as_needed(self):
1378813788 which is the default mode on Linux unless using another arg."""
1378913789 if "linux" in sys.platform and (not self.headed or self.xvfb):
1379013790 from sbvirtualdisplay import Display
13791- if self.undetectable and not (self.headless or self.headless2):
13792- import Xlib.display
13793- try:
13794- self._xvfb_display = Display(
13795- visible=True,
13796- size=(1366, 768),
13797- backend="xvfb",
13798- use_xauth=True,
13799- )
13800- self._xvfb_display.start()
13801- if "DISPLAY" not in os.environ.keys():
13791+ pip_find_lock = fasteners.InterProcessLock(
13792+ constants.PipInstall.FINDLOCK
13793+ )
13794+ with pip_find_lock: # Prevent issues with multiple processes
13795+ if self.undetectable and not (self.headless or self.headless2):
13796+ import Xlib.display
13797+ try:
13798+ self._xvfb_display = Display(
13799+ visible=True,
13800+ size=(1366, 768),
13801+ backend="xvfb",
13802+ use_xauth=True,
13803+ )
13804+ self._xvfb_display.start()
13805+ if "DISPLAY" not in os.environ.keys():
13806+ print(
13807+ "\nX11 display failed! Will use regular xvfb!"
13808+ )
13809+ self.__activate_standard_virtual_display()
13810+ except Exception as e:
13811+ if hasattr(e, "msg"):
13812+ print("\n" + str(e.msg))
13813+ else:
13814+ print(e)
1380213815 print("\nX11 display failed! Will use regular xvfb!")
1380313816 self.__activate_standard_virtual_display()
13804- except Exception as e:
13805- if hasattr(e, "msg"):
13806- print("\n" + str(e.msg))
13807- else:
13808- print(e)
13809- print("\nX11 display failed! Will use regular xvfb!")
13810- self.__activate_standard_virtual_display()
13811- return
13812- pip_find_lock = fasteners.InterProcessLock(
13813- constants.PipInstall.FINDLOCK
13814- )
13815- with pip_find_lock: # Prevent issues with multiple processes
13817+ return
1381613818 pyautogui_is_installed = False
1381713819 try:
1381813820 import pyautogui
@@ -13854,8 +13856,8 @@ def __activate_virtual_display_as_needed(self):
1385413856 print("\n" + str(e.msg))
1385513857 else:
1385613858 print(e)
13857- else:
13858- self.__activate_standard_virtual_display()
13859+ else:
13860+ self.__activate_standard_virtual_display()
1385913861
1386013862 def __ad_block_as_needed(self):
1386113863 """This is an internal method for handling ad-blocking.
0 commit comments