(vm: &VirtualMachine)
| 473 | /// VmState locks to unlocked. |
| 474 | #[cfg(feature = "threading")] |
| 475 | pub fn reinit_frame_slot_after_fork(vm: &VirtualMachine) { |
| 476 | let current_ident = crate::stdlib::_thread::get_ident(); |
| 477 | let current_frames: Vec<FramePtr> = vm.frames.borrow().clone(); |
| 478 | let new_slot = Arc::new(ThreadSlot { |
| 479 | frames: parking_lot::Mutex::new(current_frames), |
| 480 | exception: crate::PyAtomicRef::from(vm.topmost_exception()), |
| 481 | #[cfg(unix)] |
| 482 | state: core::sync::atomic::AtomicI32::new(THREAD_ATTACHED), |
| 483 | #[cfg(unix)] |
| 484 | stop_requested: core::sync::atomic::AtomicBool::new(false), |
| 485 | #[cfg(unix)] |
| 486 | thread: std::thread::current(), |
| 487 | }); |
| 488 | |
| 489 | // Lock is safe: reinit_locks_after_fork() already reset it to unlocked. |
| 490 | let mut registry = vm.state.thread_frames.lock(); |
| 491 | registry.clear(); |
| 492 | registry.insert(current_ident, new_slot.clone()); |
| 493 | drop(registry); |
| 494 | |
| 495 | CURRENT_THREAD_SLOT.with(|s| { |
| 496 | *s.borrow_mut() = Some(new_slot); |
| 497 | }); |
| 498 | } |
| 499 | |
| 500 | pub fn with_vm<F, R>(obj: &PyObject, f: F) -> Option<R> |
| 501 | where |
no test coverage detected