I initiated and close phantomjs
in Python with the following
from selenium import webdriver
driver = webdriver.PhantomJS()
driver.get(url)
html_doc = driver.page_source
driver.close()
yet after the script ends execution I still find an instance of phantomjs
in my Mac Activity Monitor. And actually every time I run the script a new process phantomjs
is created.
How should I close the driver?
As of July 2016, driver.close()
and driver.quit()
weren't sufficient for me. That killed the node
process but not the phantomjs
child process it spawned.
Following the discussion on this GitHub issue, the single solution that worked for me was to run:
import signal
driver.service.process.send_signal(signal.SIGTERM) # kill the specific phantomjs child proc
driver.quit() # quit the node proc