I have the following code snippet that works fine:
from pyvirtualdisplay import Display
from selenium import webdriver
display = Display(visible=0, size=(800, 600))
display.start()
browser = webdriver.Firefox()
browser.get('http://www.google.com')
print(browser.title)
browser.quit()
display.stop()
but when I ignore SIGCHLD signal by adding
import signal
signal.signal(signal.SIGCHLD, signal.SIG_IGN)
to the beginning of the code I receive the following error:
selenium.common.exceptions.WebDriverException: Message: "The browser appears to have exited before we could connect. The output was: b'Error: cannot open display: :1127\n'
How does ignoring SIGCHLD relates to display? And how to work around it?
Finally I solved this problem by processing SIGCHLD, not ignoring it:
def sigchld_nahdler(signum, frame):
os.waitpid(0, 0)
signal.signal(signal.SIGCHLD, sigchld_handler)