We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents fa990ab + f73dbff commit 7895716Copy full SHA for 7895716
surfa/system.py
@@ -93,15 +93,18 @@ def hostname(short=True):
93
return node
94
95
96
-def vmpeak():
+def vmpeak(pid=None):
97
"""
98
Return the peak memory usage of the process in kilobytes.
99
100
Note: This only works on linux machines because it requires `/proc/self/status`.
101
102
# TODO: switch to this (portable across platforms)
103
# return resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
104
- procstatus = '/proc/self/status'
+ if (pid is None):
105
+ procstatus = '/proc/self/status'
106
+ else:
107
+ procstatus = os.path.join('/proc', str(pid), 'status')
108
if os.path.exists(procstatus):
109
with open(procstatus, 'r') as file:
110
for line in file:
0 commit comments