Skip to content

Commit

Permalink
Fix Process cpu_percent on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreF committed Jan 19, 2017
1 parent db5776b commit e1a9376
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
5 changes: 5 additions & 0 deletions CREDITS
Original file line number Diff line number Diff line change
Expand Up @@ -420,3 +420,8 @@ I: 919
N: Max Bélanger
W: https://github.com/maxbelanger
I: 936

N: Pierre Fersing
C: France
E: [email protected]
I: 950
2 changes: 2 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
- 687_: [Linux] pid_exists() no longer returns True if passed a process thread
ID.
- 948_: cannot install psutil with PYTHONOPTIMIZE=2.
- 950_: [Windows] Process.cpu_percent() was calculated incorrectly and showed
higher number than real usage.


5.0.1
Expand Down
9 changes: 2 additions & 7 deletions psutil/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1007,13 +1007,8 @@ def cpu_percent(self, interval=None):
raise ValueError("interval is not positive (got %r)" % interval)
num_cpus = cpu_count() or 1

if POSIX:
def timer():
return _timer() * num_cpus
else:
def timer():
t = cpu_times()
return sum((t.user, t.system))
def timer():
return _timer() * num_cpus

if blocking:
st1 = timer()
Expand Down

0 comments on commit e1a9376

Please sign in to comment.