Python psutil 模块,STATUS_RUNNING 实例源码

我们从Python开源项目中,提取了以下4个代码示例,用于说明如何使用psutil.STATUS_RUNNING

项目:respeaker_virtualenv    作者:respeaker    | 项目源码 | 文件源码
def test_status(self):
        p = psutil.Process()
        self.assertEqual(p.status(), psutil.STATUS_RUNNING)
项目:zenchmarks    作者:squeaky-pl    | 项目源码 | 文件源码
def test_status(self):
        p = psutil.Process()
        self.assertEqual(p.status(), psutil.STATUS_RUNNING)
项目:FancyWord    作者:EastonLee    | 项目源码 | 文件源码
def test_status(self):
        p = psutil.Process()
        self.assertEqual(p.status(), psutil.STATUS_RUNNING)
项目:Scalable-PaQL-Queries    作者:mattfeel    | 项目源码 | 文件源码
def check_current_running_experiments(expdb):
    sql = "SELECT *, NOW() - starttime AS time_elapsed " \
          "FROM exp " \
          "WHERE status = 'running' " \
          "ORDER BY starttime, id "
    exps = []

    for exp in list(expdb.sql_query(sql)):
        if exp.pid is not None:
            # Just check if process is still alive
            try:
                # print "Checking pid = {}".format(exp.pid)
                # os.kill(exp.pid, 0)
                proc = psutil.Process(exp.pid)
            except psutil.NoSuchProcess:
                # print "pid is dead"
                if exp.manager_uuid != manager_uuid:
                    set_experiment_as_error(expdb, exp, "daemon crashed")
                else:
                    raise Exception
            else:
                if proc.status() == psutil.STATUS_ZOMBIE:
                    set_experiment_as_error(expdb, exp, "zombie")
                elif proc.status() == psutil.STATUS_RUNNING:
                    # print "pid is alive and running"
                    exps.append(exp)
                else:
                    raise Exception("Process (pid={}) status `{}' not supported.".format(exp.pid, proc.status()))

        else:
            set_experiment_as_error(expdb, exp, "no pid")

    return exps