pyqt_reactive.services.process_tracker

Process Tracker Utility

Tracks which processes are currently alive for log file status indication. Used by log viewer to distinguish logs from running vs terminated processes.

Functions

extract_pid_from_log_filename(log_path)

Extract PID from application log filename.

get_log_display_name(log_path, process_tracker)

Get display name for log file with process status indicator.

get_log_tooltip(log_path, process_tracker)

Get tooltip text for log file with process information.

Classes

ProcessInfo(pid, name, status, create_time)

Information about a tracked process.

ProcessTracker()

Tracks which processes are currently alive.

class pyqt_reactive.services.process_tracker.ProcessInfo(pid: int, name: str, status: str, create_time: float)[source]

Information about a tracked process.

pid: int
name: str
status: str
create_time: float
__init__(pid: int, name: str, status: str, create_time: float) None
class pyqt_reactive.services.process_tracker.ProcessTracker[source]

Tracks which processes are currently alive.

Used to determine if log files correspond to running or terminated processes.

__init__()[source]

Initialize process tracker.

alive_pids: Set[int]
process_info: dict[int, ProcessInfo]
update(target_pids: Iterable[int] | None = None) bool[source]

Update tracked process state.

Parameters:

target_pids – Optional PID set to check directly. When provided, avoids scanning every process on the machine.

Returns:

True when tracked alive/dead state changed.

is_alive(pid: int | None) bool[source]

Check if a PID is currently alive.

Parameters:

pid – Process ID to check (None returns False)

Returns:

True if process is alive, False otherwise

Return type:

bool

get_process_info(pid: int) ProcessInfo | None[source]

Get information about a process.

Parameters:

pid – Process ID

Returns:

ProcessInfo if process is alive, None otherwise

get_status_icon(pid: int | None) str[source]

Get status icon for a process.

Parameters:

pid – Process ID (None returns unknown icon)

Returns:

Status icon (🟢 alive, ⚫ dead, ❓ unknown)

Return type:

str

get_status_text(pid: int | None) str[source]

Get human-readable status text for a process.

Parameters:

pid – Process ID (None returns “Unknown”)

Returns:

Status text (“Running”, “Terminated”, “Unknown”)

Return type:

str

pyqt_reactive.services.process_tracker.extract_pid_from_log_filename(log_path: Path) int | None[source]

Extract PID from application log filename.

Supports various log filename patterns: - app_unified_20251007_102845_worker_12345.log - zmq_worker_exec_abc123_worker_12345.log - app_worker_12345.log

Parameters:

log_path – Path to log file

Returns:

Extracted PID, or None if no PID found

Return type:

int

pyqt_reactive.services.process_tracker.get_log_display_name(log_path: Path, process_tracker: ProcessTracker) str[source]

Get display name for log file with process status indicator.

Parameters:
  • log_path – Path to log file

  • process_tracker – ProcessTracker instance

Returns:

Display name with status icon (e.g., “🟢 worker_12345.log”)

Return type:

str

pyqt_reactive.services.process_tracker.get_log_tooltip(log_path: Path, process_tracker: ProcessTracker) str[source]

Get tooltip text for log file with process information.

Parameters:
  • log_path – Path to log file

  • process_tracker – ProcessTracker instance

Returns:

Tooltip text with process status and info

Return type:

str