本文整理汇总了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
示例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
示例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}