tools/mac/power/driver.py
def Teardown(self):
    """Cleans up global state after all calls to Record()/Profile().

    Makes sure that all processes started for measurement/profiling are exited
    and that the execution can move on to the next one.
    """

    # Cleanup can't be achieved with a simple call to psutil.waitprocs() because
    # some executables are started with sudo and will end up as a zombie
    # processes.
    for process in self._started_processeds:
      logging.info(f"Terminating PID:{process.pid}")

      try:
        process.terminate()
        process.wait(0.5)
      except psutil.NoSuchProcess:
        continue
      except (psutil.TimeoutExpired, psutil.AccessDenied) as e:
        logging.info(f"Terminate failed, moving on to kill.")

      try:
        process.kill()
        process.wait(0.5)
      except psutil.NoSuchProcess:
        continue
      except (psutil.TimeoutExpired, psutil.AccessDenied) as e:
        logging.info(f"Kill failed, trying sudo kill.")

      try:
        os.system(f"sudo kill {process.pid}")
        process.wait(0.5)
      except psutil.NoSuchProcess:
        continue
      except psutil.TimeoutExpired:
        logging.error(f"Could not clean up PID:{process.pid}. Aborting")
        sys.exit(-1)

    # Start over for next round.
    self._started_processeds.clear()
Cleans up global state after all calls to Record()/Profile().

    Makes sure that all processes started for measurement/profiling are exited
    and that the execution can move on to the next one.
    
Cleans up global state after all calls to Record()/Profile().
Makes sure that all processes started for measurement/profiling are exited
and that the execution can move on to the next one.
Cleans up global state after all calls to Record () / Profile () . Makes sure that all processes started for measurement / profiling are exited and that the execution can move on to the next one .
def Teardown(self):
    for process in self._started_processeds:
      logging.info(f"Terminating PID:{process.pid}")
      try:
        process.terminate()
        process.wait(0.5)
      except psutil.NoSuchProcess:
        continue
      except (psutil.TimeoutExpired, psutil.AccessDenied) as e:
        logging.info(f"Terminate failed, moving on to kill.")
      try:
        process.kill()
        process.wait(0.5)
      except psutil.NoSuchProcess:
        continue
      except (psutil.TimeoutExpired, psutil.AccessDenied) as e:
        logging.info(f"Kill failed, trying sudo kill.")
      try:
        os.system(f"sudo kill {process.pid}")
        process.wait(0.5)
      except psutil.NoSuchProcess:
        continue
      except psutil.TimeoutExpired:
        logging.error(f"Could not clean up PID:{process.pid}. Aborting")
        sys.exit(-1)
    self._started_processeds.clear()
def Teardown ( self ) : for process in self . _started_processeds : logging . info ( f"Terminating PID:{process.pid}" ) try : process . terminate ( ) process . wait ( 0.5 ) except psutil . NoSuchProcess : continue except ( psutil . TimeoutExpired , psutil . AccessDenied ) as e : logging . info ( f"Terminate failed, moving on to kill." ) try : process . kill ( ) process . wait ( 0.5 ) except psutil . NoSuchProcess : continue except ( psutil . TimeoutExpired , psutil . AccessDenied ) as e : logging . info ( f"Kill failed, trying sudo kill." ) try : os . system ( f"sudo kill {process.pid}" ) process . wait ( 0.5 ) except psutil . NoSuchProcess : continue except psutil . TimeoutExpired : logging . error ( f"Could not clean up PID:{process.pid}. Aborting" ) sys . exit ( - 1 ) self . _started_processeds . clear ( )
Cleans up global state after all calls to Record()/Profile().
Cleans up global state after all calls to Record () / Profile () .
"""Cleans up global state after all calls to Record()/Profile().

    Makes sure that all processes started for measurement/profiling are exited
    and that the execution can move on to the next one.
    """ # Cleanup can't be achieved with a simple call to psutil.waitprocs() because # some executables are started with sudo and will end up as a zombie # processes. # Start over for next round.
self