@@ -57,6 +57,7 @@ def __init__(
5757 perfspect_path : Optional [Path ] = None ,
5858 perfspect_duration : int = 60 ,
5959 polling_rate_seconds : int = DEFAULT_POLLING_INTERVAL_SECONDS ,
60+ verbose : bool = False ,
6061 ):
6162 self ._polling_rate_seconds = polling_rate_seconds
6263 self ._stop_event = stop_event
@@ -65,6 +66,7 @@ def __init__(
6566 self ._ps_process : Optional [subprocess .Popen [bytes ]] = None
6667 self ._perfspect_path : Optional [Path ] = perfspect_path
6768 self ._perfspect_duration = perfspect_duration
69+ self ._verbose = verbose
6870
6971 self ._ps_raw_csv_filename = PERFSPECT_DATA_DIRECTORY + "/" + platform .node () + "_metrics.csv"
7072 self ._ps_summary_csv_filename = PERFSPECT_DATA_DIRECTORY + "/" + platform .node () + "_metrics_summary.csv"
@@ -93,7 +95,17 @@ def start(self) -> None:
9395 PERFSPECT_DATA_DIRECTORY ,
9496 ]
9597
98+ # Add --debug if verbose is enabled
99+ if self ._verbose :
100+ ps_cmd .append ("--debug" )
101+
96102 self ._ps_process = subprocess .Popen (ps_cmd , stdout = subprocess .PIPE )
103+ Thread (target = self ._reap_ps_process , daemon = True ).start ()
104+
105+ def _reap_ps_process (self ) -> None :
106+ if self ._ps_process is not None :
107+ self ._ps_process .wait ()
108+ self ._ps_process = None
97109
98110 def stop (self ) -> None :
99111 if self ._ps_process :
0 commit comments