本文整理汇总了Python中psutil.Process.io_counters方法的典型用法代码示例。如果您正苦于以下问题:Python Process.io_counters方法的具体用法?Python Process.io_counters怎么用?Python Process.io_counters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类psutil.Process
的用法示例。
在下文中一共展示了Process.io_counters方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: collect_sample
# 需要导入模块: from psutil import Process [as 别名]
# 或者: from psutil.Process import io_counters [as 别名]
def collect_sample(pid):
"""
retrieve current usage sample
This will be called every N seconds
pid: process id (int)
(this should have been validated before calling this function)
Return: an instance of the pstat namedtuple
"""
time_stamp = datetime.now().isoformat()
file_name1 = "/proc/{0}/stat".format(pid)
with open(file_name1) as f:
lines1 = f.readlines()
pid_process = Process(pid)
io_counters = pid_process.io_counters()
with open(FSTAT, 'r') as f:
first_line = f.readline()
return [lines1[0], first_line, time_stamp, io_counters]