How to properly stop phantomjs execution

前端 未结 7 929
星月不相逢
星月不相逢 2020-11-29 21:30

I initiated and close phantomjs in Python with the following

from selenium import webdriver    
driver = webdriver.PhantomJS()
driver.get(url)
h         


        
7条回答
  •  我在风中等你
    2020-11-29 22:03

    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
    

提交回复
热议问题