(self, pid, data_interval)
| 215 | """ |
| 216 | |
| 217 | def benchmark_process(self, pid, data_interval): |
| 218 | parent_pid = os.getpid() |
| 219 | try: |
| 220 | # Benchmark the process where the script is being run. |
| 221 | return self._run_benchmark(pid, data_interval) |
| 222 | except KeyboardInterrupt: |
| 223 | # If there is an interrupt, then try to clean everything up. |
| 224 | proc = psutil.Process(parent_pid) |
| 225 | procs = proc.children(recursive=True) |
| 226 | |
| 227 | for child in procs: |
| 228 | child.terminate() |
| 229 | |
| 230 | gone, alive = psutil.wait_procs(procs, timeout=1) |
| 231 | for child in alive: |
| 232 | child.kill() |
| 233 | raise |
| 234 | |
| 235 | def _run_benchmark(self, pid, data_interval): |
| 236 | process_to_measure = psutil.Process(pid) |
no test coverage detected