@@ -54,7 +54,7 @@ def __init__(self, pid, freq=0.2, fname=None, cwd=None):
54
54
55
55
# Leave process initialized and make first sample
56
56
self ._process = psutil .Process (pid )
57
- _sample = self ._sample (cpu_interval = 0.2 )
57
+ _first_sample = self ._sample (cpu_interval = 0.2 )
58
58
59
59
# Continue monitor configuration
60
60
freq = max (freq , 0.2 )
@@ -66,7 +66,7 @@ def __init__(self, pid, freq=0.2, fname=None, cwd=None):
66
66
self ._freq = freq
67
67
68
68
# Dump first sample to file
69
- print ("," .join (_sample ), file = self ._logfile )
69
+ print ("," .join (_first_sample ), file = self ._logfile )
70
70
self ._logfile .flush ()
71
71
72
72
# Start thread
@@ -108,6 +108,7 @@ def stop(self):
108
108
return retval
109
109
110
110
def _sample (self , cpu_interval = None ):
111
+ _time = time ()
111
112
cpu = 0.0
112
113
rss = 0.0
113
114
vms = 0.0
@@ -136,7 +137,7 @@ def _sample(self, cpu_interval=None):
136
137
except psutil .NoSuchProcess :
137
138
pass
138
139
139
- return (time () , cpu , rss / _MB , vms / _MB )
140
+ return (_time , cpu , rss / _MB , vms / _MB )
140
141
141
142
def run (self ):
142
143
"""Core monitoring function, called by start()"""
0 commit comments