A StackTrace represents the call stack for a single Python thread. It contains metadata about the thread's state and the sequence of function calls (frames) that led to the current point.
Key fields include:
pid: The process ID.thread_id: The Python thread ID.os_thread_id: The operating system thread ID.active: Boolean indicating if the thread was active.owns_gil: Boolean indicating if the thread held the Global Interpreter Lock (GIL).frames: A vector of Frame objects representing the call stack.process_info: Metadata about the process command line and parent process.
You can determine the thread's status using the status_str() method, which returns one of: "idle", "active+gil", or "active".
match stack_trace.status_str() {
"idle" => println!("Thread is waiting"),
"active+gil" => println!("Thread is running and holds the GIL"),
"active" => println!("Thread is running but does not hold the GIL"),
_ => {}
}