Skip to content

Commit b44dca1

Browse files
committed
Representable for ThreadHandle
1 parent b29c3b8 commit b44dca1

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

crates/vm/src/stdlib/thread.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1185,7 +1185,7 @@ pub(crate) mod _thread {
11851185
done_event: Arc<(parking_lot::Mutex<bool>, parking_lot::Condvar)>,
11861186
}
11871187

1188-
#[pyclass]
1188+
#[pyclass(with(Representable))]
11891189
impl ThreadHandle {
11901190
fn new(vm: &VirtualMachine) -> Self {
11911191
let inner = Arc::new(parking_lot::Mutex::new(ThreadHandleInner {
@@ -1427,6 +1427,16 @@ pub(crate) mod _thread {
14271427
}
14281428
}
14291429

1430+
impl Representable for ThreadHandle {
1431+
fn repr_str(zelf: &Py<Self>, _vm: &VirtualMachine) -> PyResult<String> {
1432+
let ident = zelf.inner.lock().ident;
1433+
Ok(format!(
1434+
"<{} object: ident={ident}>",
1435+
zelf.class().slot_name()
1436+
))
1437+
}
1438+
}
1439+
14301440
#[pyfunction]
14311441
fn start_joinable_thread(
14321442
mut f_args: FuncArgs,

0 commit comments

Comments
 (0)