Skip to content

Commit 490f182

Browse files
committed
Suppress the perf script crash with logging if it happens
Signed-off-by: Min Lim <min.yeol.lim@intel.com>
1 parent 63ef435 commit 490f182

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

gprofiler/utils/perf_process.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
wait_event,
2020
wait_for_file_by_prefix,
2121
)
22+
from gprofiler.exceptions import CalledProcessError
23+
2224

2325
logger = get_logger_adapter(__name__)
2426

@@ -189,10 +191,18 @@ def wait_and_script(self) -> str:
189191
perf_data.unlink()
190192
perf_data = inject_data
191193

192-
perf_script_proc = run_process(
193-
[perf_path(), "script", "-F", "+pid", "-i", str(perf_data)],
194-
suppress_log=True,
195-
)
194+
perf_script_cmd = [perf_path(), "script", "-F", "+pid", "-i", str(perf_data)]
195+
try:
196+
perf_script_proc = run_process(
197+
perf_script_cmd,
198+
suppress_log=True,
199+
)
200+
except CalledProcessError as e:
201+
logger.critical(
202+
f"{self._log_name} failed to run perf script: {str(e)}",
203+
command=" ".join(perf_script_cmd),
204+
)
205+
return ""
196206
return perf_script_proc.stdout.decode("utf8")
197207
finally:
198208
perf_data.unlink()

0 commit comments

Comments
 (0)