isp_data_pollution.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:isp-data-pollution 作者: essandess 项目源码 文件源码
def phantomjs_pid_and_memory(self):
        """ Return the pid and memory (MB) of the phantomjs process,
        restart if it's a zombie, and exit if a restart isn't working
        after three attempts. """
        for k in range(3):    # three strikes
            try:
                @self.phantomjs_short_timeout
                def phantomjs_process_pid(): return self.driver.service.process.pid
                pid = phantomjs_process_pid()
                rss_mb = psutil.Process(pid).memory_info().rss / float(2 ** 20)
                break
            except (psutil.NoSuchProcess,Exception) as e:
                if self.debug: print('.service.process.pid exception:\n{}'.format(e))
                self.quit_driver(pid=pid)
                self.open_driver()
        else:  # throw in the towel and exit if no viable phantomjs process after multiple attempts
            print('No viable phantomjs process after multiple attempts!')
            sys.exit(1)
        return (pid, rss_mb)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号