Answer the question
In order to leave comments, you need to log in
Why doesn't Xvfb terminate the process?
I use Selenium for scraping on a server without a gui. I am emulating an X server using pyvirtualdisplay (a wrapper for Xvfb in python).
Before opening the browser, I create a virtual display; after the scraping is done and the browser is closed, I turn off the virtual display. The parser runs every few minutes. The problem is that the display for some reason does not complete its work and after an hour I have a bunch of Xvfb processes that eat up all the processor power.
Help me figure out what I'm doing wrong.
from pyvirtualdisplay import Display
...
# создаю виртуальный дисплей
display = Display(visible=0, size=(1920, 1080))
display.start()
...
# инициализирую браузер
chrome_options.add_argument("--headless")
chrome_options.add_argument("--window-size=1920x1080")
br = webdriver.Chrome(chrome_options=chrome_options,
executable_path=webdriver_path)
# делаю свои дела
br.get(url)
...
# закрываю браузер
br.close()
# закрываю дисплей
display.stop()
Answer the question
In order to leave comments, you need to log in
End the script with either this construction:
display.popen.terminate()
Or this:
display.popen.kill()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question