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

Unified Diff: tools/telemetry/telemetry/internal/util/global_hooks.py

Issue 1379063003: [Telemetry] Move listing stray processes to more appropriate places (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 2 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 | « tools/telemetry/telemetry/benchmark_runner.py ('k') | tools/telemetry/telemetry/internal/util/ps_util.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/telemetry/internal/util/global_hooks.py
diff --git a/tools/telemetry/telemetry/internal/util/global_hooks.py b/tools/telemetry/telemetry/internal/util/global_hooks.py
index 7728234377bd597a9f8d51b04f244bf1e374b993..d34357552ea2dbcfa515eb928cf683b294936df2 100644
--- a/tools/telemetry/telemetry/internal/util/global_hooks.py
+++ b/tools/telemetry/telemetry/internal/util/global_hooks.py
@@ -3,12 +3,8 @@
# found in the LICENSE file.
"""Hooks that apply globally to all scripts that import or use Telemetry."""
-import atexit
-import inspect
-import os
import signal
import sys
-import logging
from telemetry.internal.util import exception_formatter
@@ -17,7 +13,6 @@ def InstallHooks():
InstallUnhandledExceptionFormatter()
InstallStackDumpOnSigusr1()
InstallTerminationHook()
- InstallListStrayProcessesUponExitHook()
def InstallUnhandledExceptionFormatter():
"""Print prettier exceptions that also contain the stack frame's locals."""
@@ -43,38 +38,3 @@ def InstallTerminationHook():
exception_formatter.PrintFormattedFrame(stack_frame, exception_string)
sys.exit(-1)
signal.signal(signal.SIGTERM, PrintStackAndExit)
-
-
-def InstallListStrayProcessesUponExitHook():
- def _ListAllSubprocesses():
- try:
- import psutil
- except ImportError:
- logging.error(
- 'psutil is not installed on the system. Not listing possible '
- 'leaked processes. To install psutil, see: '
- 'https://pypi.python.org/pypi/psutil')
- return
- telemetry_pid = os.getpid()
- parent = psutil.Process(telemetry_pid)
- if hasattr(parent, 'children'):
- children = parent.children(recursive=True)
- else: # Some old version of psutil use get_children instead children.
- children = parent.get_children()
- if children:
- leak_processes_info = []
- for p in children:
- if inspect.ismethod(p.name):
- name = p.name()
- else: # Process.name is a property in old versions of psutil.
- name = p.name
- process_info = '%s (%s)' % (name, p.pid)
- try:
- process_info += ' - %s' % p.cmdline()
- except Exception:
- pass
- leak_processes_info.append(process_info)
- logging.error('Telemetry leaks these processes: %s',
- ', '.join(leak_processes_info))
-
- atexit.register(_ListAllSubprocesses)
« no previous file with comments | « tools/telemetry/telemetry/benchmark_runner.py ('k') | tools/telemetry/telemetry/internal/util/ps_util.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698