本文整理汇总了Python中psutil.Process.get_ext_memory_info方法的典型用法代码示例。如果您正苦于以下问题:Python Process.get_ext_memory_info方法的具体用法?Python Process.get_ext_memory_info怎么用?Python Process.get_ext_memory_info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类psutil.Process
的用法示例。
在下文中一共展示了Process.get_ext_memory_info方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from psutil import Process [as 别名]
# 或者: from psutil.Process import get_ext_memory_info [as 别名]
#.........这里部分代码省略.........
if self.caches[key][FIELD_TYPE] == HASH_TYPE:
data = {field: self.caches[key][FIELD_VALUE][field] for field in fields if field in self.caches[key][FIELD_VALUE]}
return 1, data
else:
return 0, None
else:
return 0, None
def hgetall(self, key):
if key in self.caches:
if self.caches[key][FIELD_TYPE] == HASH_TYPE:
return 1, self.caches[key][FIELD_VALUE]
else:
return 0, None
else:
return 0, None
def hexists(self, key, field):
if key in self.caches:
if self.caches[key][FIELD_TYPE] == HASH_TYPE:
#print self.caches[key][FIELD_VALUE], field
if field in self.caches[key][FIELD_VALUE]:
return 1, 1
else:
return 1, 0
else:
return 0, None
else:
return 0, None
def hlen(self, key):
if key in self.caches:
if self.caches[key][FIELD_TYPE] == HASH_TYPE:
return 1, len(self.caches[key][FIELD_VALUE])
else:
return 0, None
else:
return 0, None
def hdel(self, key, fields):
if key in self.caches:
if self.caches[key][FIELD_TYPE] == HASH_TYPE:
for field in fields:
try:
del self.caches[key][FIELD_VALUE][field]
except KeyError:
pass
return 1, None
else:
return 0, None
else:
return 0, None
def hkeys(self, key):
if key in self.caches:
if self.caches[key][FIELD_TYPE] == HASH_TYPE:
return 1, self.caches[key][FIELD_VALUE].keys()
else:
return 0, None
else:
return 0, None
def hvals(self, key):
if key in self.caches:
if self.caches[key][FIELD_TYPE] == HASH_TYPE:
return 1, self.caches[key][FIELD_VALUE].values()
else:
return 0, None
else:
return 0, None
def get_status(self):
from pycached import __version__
status = {
'last_cmd_time': self.last_cmd_time,
'cmd_version': self.version,
'uptime_in_seconds': int(time.time() - self.start_time),
'process_id': self.process.pid,
'pycached_version': __version__,
'key_size': len(self.caches),
'next_save_key_size': len(self.keys),
'next_del_key_size': len(self.delkeys),
'expire_key_size': len(self.expirekeys),
'save_time': self.savetime,
'threads': self.process.get_num_threads(),
'used_memory': self.process.get_ext_memory_info().rss,
'used_memory_peak':self.process.get_ext_memory_info().vms,
'memory_percent': "%0.4f" % self.process.get_memory_percent(),
#'used_cpu': cpu_percent(),
}
return status
def change_version(self):
self.last_cmd_time = int(time.time())
self.version = ''.join(random.sample(string.ascii_letters, 16))