in benchmarking/profilers/perfetto/perfetto.py [0:0]
def _signalPerfetto(self) -> bool:
# signal perfetto to stop profiling and await results
getLogger().info("Stopping Perfetto profiling.")
result = None
if self.perfetto_pid is not None:
sigint_cmd = [
"kill",
"-SIGINT",
self.perfetto_pid,
"&&",
"wait",
self.perfetto_pid,
]
sigterm_cmd = ["kill", "-SIGTERM", self.perfetto_pid]
else:
sigint_cmd = ["pkill", "-SIGINT", "perfetto"]
sigterm_cmd = ["pkill", "-SIGTERM", "perfetto"]
cmd = sigint_cmd
try:
# Wait for Perfetto to finish gracefully
getLogger().info("Running '" + " ".join(cmd) + "'.")
result = self.adb.shell(
sigint_cmd,
timeout=30,
retry=1,
silent=True,
)
if self.perfetto_pid is None:
time.sleep(6.0)
return True
except Exception as e:
getLogger().exception(
f"Perfetto did not respond to SIGINT. Terminating. {e}."
)
cmd = sigterm_cmd
result = self.adb.shell(
cmd,
timeout=10,
)
return False
finally:
getLogger().info(f"Running '{' '.join(cmd)}' returned {result}.")