1

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?

Alex
  • 1,914
  • 6
  • 26
  • 47

2 Answers2

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.

Vinicius Seganfredo
  • 1,704
  • 3
  • 15
  • 21
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
Levi Noecker
  • 3,142
  • 1
  • 15
  • 30