processmanager.py 文件源码

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

项目:social-listener 作者: topix-hackademy 项目源码 文件源码
def refresh_status(self):
        """
        Refresh process status.
        If a process is dead or in zombie status a flag 'is_alive' will be setted to False
        :return:
        """
        what_time_is_now = what_time_is_it()
        for process in Connection.Instance().db.manager.find({"is_alive": True}):
            if (not psutil.pid_exists(process['pid'])) or \
                    (psutil.pid_exists(process['pid']) and psutil.Process(process['pid']).status() ==
                        psutil.STATUS_ZOMBIE):
                self.update_process(process['pid'], {
                        'is_alive': False,
                        'last_update': what_time_is_now
                    })
            elif psutil.pid_exists(process['pid']):
                self.update_process(process['pid'], {'last_update': what_time_is_now})
        logging.info('Refresh Done!')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号