Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(168)

Unified Diff: tools/telemetry/telemetry/core/chrome/win_platform_backend.py

Issue 12837013: [Telemetry] Don't crash if a process is stopped between GetChildPids() and GetMemoryStats() or GetI… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/telemetry/core/chrome/win_platform_backend.py
diff --git a/tools/telemetry/telemetry/core/chrome/win_platform_backend.py b/tools/telemetry/telemetry/core/chrome/win_platform_backend.py
index 126a1bd702fbf588ee87521525a06387c6b19195..c1004cef10b4fd4fdcb179bccbbbd670501545e6 100644
--- a/tools/telemetry/telemetry/core/chrome/win_platform_backend.py
+++ b/tools/telemetry/telemetry/core/chrome/win_platform_backend.py
@@ -5,10 +5,12 @@
import ctypes
import subprocess
try:
+ import pywintypes # pylint: disable=F0401
import win32api # pylint: disable=F0401
import win32con # pylint: disable=F0401
import win32process # pylint: disable=F0401
except ImportError:
+ pywintypes = None
win32api = None
win32con = None
win32process = None
@@ -68,16 +70,28 @@ class WinPlatformBackend(platform_backend.PlatformBackend):
return performance_info.CommitTotal * performance_info.PageSize / 1024
def GetMemoryStats(self, pid):
- memory_info = win32process.GetProcessMemoryInfo(
- self._GetProcessHandle(pid))
+ try:
+ memory_info = win32process.GetProcessMemoryInfo(
+ self._GetProcessHandle(pid))
+ except pywintypes.error, e:
+ errcode = e[0]
+ if errcode == 87: # The process may have been closed.
+ return {}
+ raise
return {'VM': memory_info['PagefileUsage'],
'VMPeak': memory_info['PeakPagefileUsage'],
'WorkingSetSize': memory_info['WorkingSetSize'],
'WorkingSetSizePeak': memory_info['PeakWorkingSetSize']}
def GetIOStats(self, pid):
- io_stats = win32process.GetProcessIoCounters(
- self._GetProcessHandle(pid))
+ try:
+ io_stats = win32process.GetProcessIoCounters(
+ self._GetProcessHandle(pid))
+ except pywintypes.error, e:
+ errcode = e[0]
+ if errcode == 87: # The process may have been closed.
+ return {}
+ raise
return {'ReadOperationCount': io_stats['ReadOperationCount'],
'WriteOperationCount': io_stats['WriteOperationCount'],
'ReadTransferCount': io_stats['ReadTransferCount'],
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698