Skip to content
Prev Previous commit
Next Next commit
Representable for ThreadHandle
  • Loading branch information
youknowone committed Mar 8, 2026
commit 396fec96b97435bbc533676e904ce952b94b60ad
12 changes: 11 additions & 1 deletion crates/vm/src/stdlib/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1185,7 +1185,7 @@ pub(crate) mod _thread {
done_event: Arc<(parking_lot::Mutex<bool>, parking_lot::Condvar)>,
}

#[pyclass]
#[pyclass(with(Representable))]
impl ThreadHandle {
fn new(vm: &VirtualMachine) -> Self {
let inner = Arc::new(parking_lot::Mutex::new(ThreadHandleInner {
Expand Down Expand Up @@ -1427,6 +1427,16 @@ pub(crate) mod _thread {
}
}

impl Representable for ThreadHandle {
fn repr_str(zelf: &Py<Self>, _vm: &VirtualMachine) -> PyResult<String> {
let ident = zelf.inner.lock().ident;
Ok(format!(
"<{} object: ident={ident}>",
zelf.class().slot_name()
))
}
}

#[pyfunction]
fn start_joinable_thread(
mut f_args: FuncArgs,
Expand Down