2

I have a multiprocess program that creates new instances of chrome web driver, but after a while I see the number of chrome processes gets very high (2300!!) :

opt/google/chrome/chrome --disable-background-networking --disable-client-side-phishing-detection --disable-default-apps --disable-hang-monitor --disable-infobars --disable-popup-blocking --disable-prompt-on-repost 

I tried to kill any chrome process which are still alive after quitting the driver using this code:

mydisplay = Display(visible=0, size=(1024, 768)) mydisplay.start() mydriver = webdriver.Chrome('driver path') PIDs = psutil.Process(mydriver.service.process.pid).children(recursive=True) self.driver.quit() self.display.stop() for p in PIDs: try: p.kill() except: print 'no process to kill' 

But when it runs, there still some 'chrome' processes left behind. Any idea of the root cause of the problem and how to resolve it?

3 Answers 3

1

Assuming you are using linux, you might be experiencing this: Chromedriver frequently hangs when attempting to start a new session

The solution is to add DBUS_SESSION_BUS_ADDRESS=/dev/null to your environment variables:

  • export DBUS_SESSION_BUS_ADDRESS=/dev/null
  • $ DBUS_SESSION_BUS_ADDRESS=/dev/null python myscript.py
Sign up to request clarification or add additional context in comments.

Comments

1

I was having the same problem and the solution was to kill all the chromedriver.exe processes by name on the TestCleanup. Since I'm not used to python, I found this question that may help you doing that.

EDIT: I had this problem recently and the solution was to start using driver.Quit() instead of driver.Close().

While driver.Close() will simply close the driver (and can also be used to close tabs), driver.Quit() will close the browser and also kill any processes related to that instance.

Comments

0

I decided to do it this way: I get the PID every time I start up a new browser and append it to global list, and have a function on loop that kills all the chrome processes if their id is not on the list. Works for me

1 Comment

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.