Skip to content Skip to sidebar Skip to footer

Selenium Webdriver + PhantomJS Processes Not Closing

Here's just about the simplest open and close you can do with webdriver and phantom: from selenium import webdriver crawler = webdriver.PhantomJS() crawler.set_window_

Solution 1:

Go figure. Problem resolved with a reboot.


Solution 2:

Rebooting is not a solution for this problem. I have experimented this hack in LINUX system. Try modifying the stop() function defined in service.py

def stop(self):
    """
    Cleans up the process
    """
    if self._log:
        self._log.close()
        self._log = None
    #If its dead dont worry
    if self.process is None:
        return

    #Tell the Server to properly die in case
    try:
        if self.process:
            self.process.stdin.close()
            #self.process.kill()
            self.process.send_signal(signal.SIGTERM)
            self.process.wait()
            self.process = None
    except OSError:
        # kill may not be available under windows environment
        pass

Added line send_signal explicitly to give the signal to quit phantomjs process. Don't forget to add import signal statement at start of this file.


Post a Comment for "Selenium Webdriver + PhantomJS Processes Not Closing"