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


Python Process.memory_full_info方法代码示例

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


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

示例1: get_this_psutil_process

# 需要导入模块: from psutil import Process [as 别名]
# 或者: from psutil.Process import memory_full_info [as 别名]
def get_this_psutil_process():
    # Depends on psutil. Defer the import until needed, who knows what
    # it imports (psutil imports subprocess which on Python 3 imports
    # selectors. This can expose issues with monkey-patching.)
    # Returns a freshly queried object each time.
    try:
        from psutil import Process, AccessDenied
        # Make sure it works (why would we be denied access to our own process?)
        try:
            proc = Process()
            proc.memory_full_info()
        except AccessDenied: # pragma: no cover
            proc = None
    except ImportError:
        proc = None
    return proc
开发者ID:gevent,项目名称:gevent,代码行数:18,代码来源:_compat.py

示例2: _get_process

# 需要导入模块: from psutil import Process [as 别名]
# 或者: from psutil.Process import memory_full_info [as 别名]
    def _get_process(self): # pylint:disable=method-hidden
        try:
            # The standard library 'resource' module doesn't provide
            # a standard way to get the RSS measure, only the maximum.
            # You might be tempted to try to compute something by adding
            # together text and data sizes, but on many systems those come back
            # zero. So our only option is psutil.
            from psutil import Process, AccessDenied
            # Make sure it works (why would we be denied access to our own process?)
            try:
                proc = Process()
                proc.memory_full_info()
            except AccessDenied: # pragma: no cover
                proc = None
        except ImportError:
            proc = None

        self._get_process = lambda: proc
        return proc
开发者ID:wwqgtxx,项目名称:wwqLyParse,代码行数:21,代码来源:_monitor.py

示例3: SupervisorProcess

# 需要导入模块: from psutil import Process [as 别名]
# 或者: from psutil.Process import memory_full_info [as 别名]
class SupervisorProcess(object):

    def __init__(self, name, group, pid, state, statename, start, **kwargs):
        self.name = name
        self.group = group
        if statename == 'STOPPED':
            self.pid = None
            self.cpu_stats = None
            self.process = None
        else:
            self.pid = int(pid)
            self.cpu_stats = CPUStats(self.pid)
            try:
                self.process = Process(self.pid)
            except NoSuchProcess:
                self.process = None
        self.state = state
        self.statename = statename
        self.start = start
        self.stats = []

    def update(self, pid, statename, start, **kwargs):
        if statename == 'STOPPED':
            self.pid = None
            self.cpu_stats = None
            self.process = None
        else:
            if pid != self.pid:
                self.pid = int(pid)
                self.cpu_stats = CPUStats(self.pid)
                try:
                    self.process = Process(self.pid)
                except NoSuchProcess:
                    self.process = None
        self.statename = statename
        self.state = STATE_MAP[statename]
        self.start = start

    def sample(self):
        timestamp = time()
        if self.cpu_stats:
            user_util, sys_util = self.cpu_stats.cpu_percent_change()
        else:
            user_util = 0.0

        if self.process:
            try:
                # http://www.pybloggers.com/psutil-4-0-0-and-how-to-get-real-process-memory-and-environ-in-python/
                memory = self.process.memory_full_info().uss
            except NoSuchProcess:
                memory = 0
        else:
            try:
                self.process = Process(self.pid)
                memory = self.process.memory_full_info().uss
            except NoSuchProcess:
                memory = 0
        self.stats.append([timestamp, user_util, memory])

    def reset(self):
        self.stats = []

    def state_update(self):
        return {'state': {'name': self.name,
                          'group': self.group, 'pid': self.pid,
                          'state': self.state, 'statename': self.statename,
                          'start': self.start}}

    def __repr__(self):
        return '<SupervisorProcess (name: {self.name}, group: {self.group}, '
        'pid: {self.pid}, start: {self.start}, state: {self.state}, '
        'statename: {self.statename}, stats: {self.stats})'.format(self=self)

    def __json__(self):
        return {'name': self.name, 'group': self.group,
                'pid': self.pid, 'state': self.state,
                'start': self.start, 'stats': self.stats,
                'statename': self.statename}
开发者ID:silverfernsys,项目名称:supervisoragent,代码行数:80,代码来源:processmonitor.py


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