当前位置: 首页>>代码示例>>Python>>正文


Python psutil.STATUS_ZOMBIE属性代码示例

本文整理汇总了Python中psutil.STATUS_ZOMBIE属性的典型用法代码示例。如果您正苦于以下问题:Python psutil.STATUS_ZOMBIE属性的具体用法?Python psutil.STATUS_ZOMBIE怎么用?Python psutil.STATUS_ZOMBIE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在psutil的用法示例。


在下文中一共展示了psutil.STATUS_ZOMBIE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: crawl_connections

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import STATUS_ZOMBIE [as 别名]
def crawl_connections():
    created_since = -1

    proc_list = psutil.process_iter()

    for p in proc_list:
        pid = (p.pid() if hasattr(p.pid, '__call__') else p.pid)
        status = (p.status() if hasattr(p.status, '__call__'
                                        ) else p.status)
        if status == psutil.STATUS_ZOMBIE:
            continue

        create_time = (
            p.create_time() if hasattr(
                p.create_time,
                '__call__') else p.create_time)
        name = (p.name() if hasattr(p.name, '__call__') else p.name)

        if create_time <= created_since:
            continue
        for conn in p.get_connections():
            yield crawl_single_connection(conn, pid, name) 
开发者ID:cloudviz,项目名称:agentless-system-crawler,代码行数:24,代码来源:connection_utils.py

示例2: on_ready

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import STATUS_ZOMBIE [as 别名]
def on_ready():
    await asyncio.sleep(1)
    voice_channel = client.get_channel(int(voice_id))
    while not client.is_closed():
        vc = await voice_channel.connect()
        vc.play(discord.FFmpegPCMAudio(filename))
        vc.source = discord.PCMVolumeTransformer(vc.source)
        vc.source.volume = 10.0
        while vc.is_playing():
            if sys.platform.startswith('linux'):
                proc = psutil.Process(int(parentprocess))
                if proc.status() == psutil.STATUS_ZOMBIE:
                    await client.logout()
                    sys.exit()
            if not psutil.pid_exists(int(parentprocess)):  # Parent is dead, Kill self :cry:
                await client.logout()
                sys.exit()
            await asyncio.sleep(0.5)
        await vc.disconnect(force=True) 
开发者ID:DeadBread76,项目名称:Raid-Toolbox,代码行数:21,代码来源:vcspam.py

示例3: BlockOnProcessPID

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import STATUS_ZOMBIE [as 别名]
def BlockOnProcessPID(self, pid, create_time, timeout=None):
        if pid is None:
            return
        p = None
        try:
            p = self.GetProcessByPID(pid, create_time)
            if p is not None and p.is_running() and p.status not in [psutil.STATUS_ZOMBIE, psutil.STATUS_DEAD]:
                val = p.wait(timeout)
                if val is None:
                    self.logger.debug("Process is terminated ")
                else:
                    self.logger.debug("Process is terminated, possibly by os ")
        except psutil.TimeoutExpired:
            self.logger.info("TimeoutExpired happens")
            if p is not None:
                self.logger.info("kill process")
                self.TerminateProcessTree(pid, create_time)
        except Exception:
            self.logger.debug("Process is terminated for unknown reasons")
            pass
        return 
开发者ID:openweave,项目名称:happy,代码行数:23,代码来源:HappyProcess.py

示例4: _cleanup_worker_processes

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import STATUS_ZOMBIE [as 别名]
def _cleanup_worker_processes(self):
        # cleanup children
        to_remove = []
        for pid, child in self._processes.items():
            try:
                name, status = child.name(), child.status()
            except psutil.NoSuchProcess:  # May be untimely deceased
                name, status = "unknown", "unknown"
            logger.debug("  child: name=%s pid=%d status=%s" % (name, child.pid, status))
            if status in (psutil.STATUS_ZOMBIE, "unknown"):
                logger.debug("  process {} is zombie, will cleanup".format(child.pid))
                # join process to clean it up
                child.wait()
                # set the process to be removed from self._processes
                to_remove.append(pid)

        # cleanup our internal state (self._processes)
        for pid in to_remove:
            del self._processes[pid] 
开发者ID:botify-labs,项目名称:simpleflow,代码行数:21,代码来源:supervisor.py

示例5: exists

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import STATUS_ZOMBIE [as 别名]
def exists(pid, time, delta_seconds=3, zombie_seconds=10):
    if not ps.pid_exists(pid):
        log.debug(f'Process {pid} does not exist')
        return False
    process = ps.Process(pid)
    if process.status() == ps.STATUS_ZOMBIE:
        try:
            log.warning(f'Waiting for zombie {pid}')
            process.wait(zombie_seconds)
        except ps.TimeoutExpired:
            log.debug(f'Timeout waiting for zombie {pid}')
        return False
    elif delta_seconds:
        creation_ok = abs(process.create_time() - time.timestamp()) < delta_seconds
        if creation_ok:
            log.debug(f'Process {pid} still exists')
        else:
            log.debug(f'Creation time for process {pid} incorrect ({process.create_time()} / {time.timestamp()})')
        return creation_ok
    else:
        log.debug(f'Assuming process {pid} is same as expected')
        return True   # if delta_seconds = 0 don't check, just assume same 
开发者ID:andrewcooke,项目名称:choochoo,代码行数:24,代码来源:system.py

示例6: set_zombie_refresh_to_fail

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import STATUS_ZOMBIE [as 别名]
def set_zombie_refresh_to_fail(self, refresh_job):
        current_pid = refresh_job.pid
        if current_pid is None:
            return

        p = psutil.Process(current_pid)
        if p.status() != psutil.STATUS_ZOMBIE:
            return

        refresh = self.schematizer.get_refresh_by_id(
            refresh_job.refresh_id
        )
        if refresh.status == RefreshStatus.IN_PROGRESS:
            # Must update manually (not relying on the signal),
            # as the process may not properly handle the signal
            # if it's a zombie
            self.schematizer.update_refresh(
                refresh_id=refresh_job.refresh_id,
                status=RefreshStatus.FAILED,
                offset=0
            )
            source = refresh_job.source
            del self.active_refresh_jobs[source]
        os.kill(current_pid, signal.SIGINT) 
开发者ID:Yelp,项目名称:data_pipeline,代码行数:26,代码来源:refresh_manager.py

示例7: crawl

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import STATUS_ZOMBIE [as 别名]
def crawl(self, vm_desc, **kwargs):
        created_since = -1

        if psvmi is None:
            raise NotImplementedError()
        else:
            (domain_name, kernel_version, distro, arch) = vm_desc
            # XXX: this has to be read from some cache instead of
            # instead of once per plugin/feature
            vm_context = psvmi.context_init(
                domain_name, domain_name, kernel_version, distro, arch)
            proc_list = psvmi.process_iter(vm_context)

        for p in proc_list:
            pid = (p.pid() if hasattr(p.pid, '__call__') else p.pid)
            status = (p.status() if hasattr(p.status, '__call__'
                                            ) else p.status)
            if status == psutil.STATUS_ZOMBIE:
                continue

            create_time = (
                p.create_time() if hasattr(
                    p.create_time,
                    '__call__') else p.create_time)
            name = (p.name() if hasattr(p.name, '__call__') else p.name)

            if create_time <= created_since:
                continue
            for conn in p.get_connections():
                yield crawl_single_connection(conn, pid, name) 
开发者ID:cloudviz,项目名称:agentless-system-crawler,代码行数:32,代码来源:connection_vm_crawler.py

示例8: test_create_zombie_proc

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import STATUS_ZOMBIE [as 别名]
def test_create_zombie_proc(self):
        zpid = create_zombie_proc()
        self.addCleanup(reap_children, recursive=True)
        p = psutil.Process(zpid)
        self.assertEqual(p.status(), psutil.STATUS_ZOMBIE) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:7,代码来源:test_misc.py

示例9: test_zombie_process_status_w_exc

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import STATUS_ZOMBIE [as 别名]
def test_zombie_process_status_w_exc(self):
        # Emulate a case where internally status() raises
        # ZombieProcess.
        p = psutil.Process()
        with mock.patch("psutil._psplatform.Process.status",
                        side_effect=psutil.ZombieProcess(0)) as m:
            self.assertEqual(p.status(), psutil.STATUS_ZOMBIE)
            assert m.called 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:10,代码来源:test_process.py

示例10: create_time

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import STATUS_ZOMBIE [as 别名]
def create_time(self, ret, proc):
        self.assertIsInstance(ret, float)
        try:
            self.assertGreaterEqual(ret, 0)
        except AssertionError:
            # XXX
            if OPENBSD and proc.status() == psutil.STATUS_ZOMBIE:
                pass
            else:
                raise
        # this can't be taken for granted on all platforms
        # self.assertGreaterEqual(ret, psutil.boot_time())
        # make sure returned value can be pretty printed
        # with strftime
        time.strftime("%Y %m %d %H:%M:%S", time.localtime(ret)) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:17,代码来源:test_contracts.py

示例11: test_pidtask_info

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import STATUS_ZOMBIE [as 别名]
def test_pidtask_info(self):
        self.assertEqual(self.p.status(), psutil.STATUS_ZOMBIE)
        self.p.ppid()
        self.p.uids()
        self.p.gids()
        self.p.terminal()
        self.p.create_time() 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:9,代码来源:test_osx.py

示例12: test_zombie_process

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import STATUS_ZOMBIE [as 别名]
def test_zombie_process(self):
        def succeed_or_zombie_p_exc(fun):
            try:
                return fun()
            except (psutil.ZombieProcess, psutil.AccessDenied):
                pass

        parent, zombie = self.spawn_zombie()
        # A zombie process should always be instantiable
        zproc = psutil.Process(zombie.pid)
        # ...and at least its status always be querable
        self.assertEqual(zproc.status(), psutil.STATUS_ZOMBIE)
        # ...and it should be considered 'running'
        assert zproc.is_running()
        # ...and as_dict() shouldn't crash
        zproc.as_dict()
        # ...its parent should 'see' it (edit: not true on BSD and MACOS
        # descendants = [x.pid for x in psutil.Process().children(
        #                recursive=True)]
        # self.assertIn(zpid, descendants)
        # XXX should we also assume ppid be usable?  Note: this
        # would be an important use case as the only way to get
        # rid of a zombie is to kill its parent.
        # self.assertEqual(zpid.ppid(), os.getpid())
        # ...and all other APIs should be able to deal with it

        ns = process_namespace(zproc)
        for fun, name in ns.iter(ns.all):
            succeed_or_zombie_p_exc(fun)

        assert psutil.pid_exists(zproc.pid)
        if not TRAVIS and MACOS:
            # For some reason this started failing all of the sudden.
            # Maybe they upgraded MACOS version?
            # https://travis-ci.org/giampaolo/psutil/jobs/310896404
            self.assertIn(zproc.pid, psutil.pids())
            self.assertIn(zproc.pid, [x.pid for x in psutil.process_iter()])
            psutil._pmap = {}
            self.assertIn(zproc.pid, [x.pid for x in psutil.process_iter()]) 
开发者ID:giampaolo,项目名称:psutil,代码行数:41,代码来源:test_process.py

示例13: create_time

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import STATUS_ZOMBIE [as 别名]
def create_time(self, ret, info):
        self.assertIsInstance(ret, float)
        try:
            self.assertGreaterEqual(ret, 0)
        except AssertionError:
            # XXX
            if OPENBSD and info['status'] == psutil.STATUS_ZOMBIE:
                pass
            else:
                raise
        # this can't be taken for granted on all platforms
        # self.assertGreaterEqual(ret, psutil.boot_time())
        # make sure returned value can be pretty printed
        # with strftime
        time.strftime("%Y %m %d %H:%M:%S", time.localtime(ret)) 
开发者ID:giampaolo,项目名称:psutil,代码行数:17,代码来源:test_contracts.py

示例14: test_spawn_zombie

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import STATUS_ZOMBIE [as 别名]
def test_spawn_zombie(self):
        parent, zombie = self.spawn_zombie()
        self.assertEqual(zombie.status(), psutil.STATUS_ZOMBIE) 
开发者ID:giampaolo,项目名称:psutil,代码行数:5,代码来源:test_testutils.py

示例15: list

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import STATUS_ZOMBIE [as 别名]
def list():
    """List running TensorBoard instances."""

    running_list = []
    parser = argparse.ArgumentParser()
    parser.add_argument('--logdir')
    parser.add_argument('--port')
    for p in psutil.process_iter():
      if p.name() != 'tensorboard' or p.status() == psutil.STATUS_ZOMBIE:
        continue
      cmd_args = p.cmdline()
      del cmd_args[0:2]  # remove 'python' and 'tensorboard'
      args = parser.parse_args(cmd_args)
      running_list.append({'pid': p.pid, 'logdir': args.logdir, 'port': args.port})
    return pd.DataFrame(running_list) 
开发者ID:googledatalab,项目名称:pydatalab,代码行数:17,代码来源:_tensorboard.py


注:本文中的psutil.STATUS_ZOMBIE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。