Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use process_exe() everywhere #277

Merged
merged 1 commit into from
Jan 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions gprofiler/profilers/java.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from granulate_utils.linux import ns, proc_events
from granulate_utils.linux.ns import get_proc_root_path, resolve_proc_root_links, run_in_ns
from granulate_utils.linux.oom import get_oom_entry
from granulate_utils.linux.process import is_process_running
from granulate_utils.linux.process import is_process_running, process_exe
from granulate_utils.linux.signals import get_signal_entry
from packaging.version import Version
from psutil import Process
Expand Down Expand Up @@ -669,7 +669,8 @@ def _check_jvm_type_supported(self, process: Process, java_version_output: str)
return True

def _is_jvm_profiling_supported(self, process: Process) -> bool:
process_basename = os.path.basename(process.exe())
exe = process_exe(process)
process_basename = os.path.basename(exe)
if JavaSafemodeOptions.JAVA_EXTENDED_VERSION_CHECKS in self._java_safemode:
# TODO we can get the "java" binary by extracting the java home from the libjvm path,
# then check with that instead (if exe isn't java)
Expand All @@ -678,7 +679,7 @@ def _is_jvm_profiling_supported(self, process: Process) -> bool:
"Non-java basenamed process, skipping... (disable "
f" --java-safemode={JavaSafemodeOptions.JAVA_EXTENDED_VERSION_CHECKS} to profile it anyway)",
pid=process.pid,
exe=process.exe(),
exe=exe,
)
return False

Expand Down
4 changes: 2 additions & 2 deletions gprofiler/profilers/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from threading import Event
from typing import Dict, List, Optional

from granulate_utils.linux.process import is_process_running
from granulate_utils.linux.process import is_process_running, process_exe
from psutil import NoSuchProcess, Process

from gprofiler.exceptions import (
Expand Down Expand Up @@ -174,7 +174,7 @@ def _select_processes_to_profile(self) -> List[Process]:
# when invoked on pypy.
# I'm checking for "pypy" in the basename here. I'm not aware of libpypy being directly loaded
# into non-pypy processes, if we ever encounter that - we can check the maps instead
if os.path.basename(process.exe()).startswith("pypy"):
if os.path.basename(process_exe(process)).startswith("pypy"):
continue

filtered_procs.append(process)
Expand Down
3 changes: 2 additions & 1 deletion gprofiler/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import importlib_resources
import psutil
from granulate_utils.linux.ns import run_in_ns
from granulate_utils.linux.process import process_exe
from psutil import Process

from gprofiler.exceptions import (
Expand Down Expand Up @@ -266,7 +267,7 @@ def pgrep_exe(match: str) -> List[Process]:
procs = []
for process in psutil.process_iter():
try:
if pattern.match(process.exe()):
if pattern.match(process_exe(process)):
procs.append(process)
except psutil.NoSuchProcess: # process might have died meanwhile
adi-benz marked this conversation as resolved.
Show resolved Hide resolved
continue
Expand Down