Check if a process is alive using psutil (more reliable than kernel32 on Windows).
(pid: int)
| 43 | |
| 44 | |
| 45 | def _is_process_alive_psutil(pid: int) -> bool: |
| 46 | """Check if a process is alive using psutil (more reliable than kernel32 on Windows).""" |
| 47 | try: |
| 48 | import psutil |
| 49 | |
| 50 | return psutil.pid_exists(pid) |
| 51 | except KeyboardInterrupt as ki: |
| 52 | handle_keyboard_interrupt(ki) |
| 53 | raise |
| 54 | except Exception: |
| 55 | # Fallback to the existing kernel32/os.kill checker |
| 56 | from ci.util.file_lock_rw_util import is_process_alive |
| 57 | |
| 58 | return is_process_alive(pid) |
| 59 | |
| 60 | |
| 61 | def _get_process_info(pid: int) -> str: |
no test coverage detected