Print output at regular intervals until interrupted. :param ostr: Stream to which to send output
(self,
interval: int,
count: Optional[int] = None,
ostr: TextIO = sys.stdout)
| 372 | self.termsize.update() |
| 373 | |
| 374 | def run(self, |
| 375 | interval: int, |
| 376 | count: Optional[int] = None, |
| 377 | ostr: TextIO = sys.stdout) -> None: |
| 378 | """ |
| 379 | Print output at regular intervals until interrupted. |
| 380 | |
| 381 | :param ostr: Stream to which to send output |
| 382 | """ |
| 383 | |
| 384 | self._load_schema() |
| 385 | self._colored = self.supports_color(ostr) |
| 386 | |
| 387 | self._print_headers(ostr) |
| 388 | |
| 389 | last_dump = json.loads(admin_socket(self.asok_path, ["perf", "dump"]).decode('utf-8')) |
| 390 | rows_since_header = 0 |
| 391 | |
| 392 | try: |
| 393 | signal(SIGWINCH, self._handle_sigwinch) |
| 394 | while True: |
| 395 | dump = json.loads(admin_socket(self.asok_path, ["perf", "dump"]).decode('utf-8')) |
| 396 | if rows_since_header >= self.termsize.rows - 2: |
| 397 | self._print_headers(ostr) |
| 398 | rows_since_header = 0 |
| 399 | self._print_vals(ostr, dump, last_dump) |
| 400 | if count is not None: |
| 401 | count -= 1 |
| 402 | if count <= 0: |
| 403 | break |
| 404 | rows_since_header += 1 |
| 405 | last_dump = dump |
| 406 | |
| 407 | # time.sleep() is interrupted by SIGWINCH; avoid that |
| 408 | end = time.time() + interval |
| 409 | while time.time() < end: |
| 410 | time.sleep(end - time.time()) |
| 411 | |
| 412 | except KeyboardInterrupt: |
| 413 | return |
| 414 | |
| 415 | def list(self, ostr: TextIO = sys.stdout) -> None: |
| 416 | """ |
nothing calls this directly
no test coverage detected