MCPcopy Index your code
hub / github.com/RustPython/RustPython / reinit_frame_slot_after_fork

Function reinit_frame_slot_after_fork

crates/vm/src/vm/thread.rs:475–498  ·  view source on GitHub ↗
(vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

473/// VmState locks to unlocked.
474#[cfg(feature = "threading")]
475pub 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
500pub fn with_vm<F, R>(obj: &PyObject, f: F) -> Option<R>
501where

Callers 1

after_fork_childFunction · 0.85

Calls 11

newFunction · 0.85
topmost_exceptionMethod · 0.80
withMethod · 0.80
borrow_mutMethod · 0.80
get_identFunction · 0.50
SomeClass · 0.50
cloneMethod · 0.45
borrowMethod · 0.45
lockMethod · 0.45
clearMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected