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

Function run_thread

crates/vm/src/stdlib/_thread.rs:568–594  ·  view source on GitHub ↗
(func: ArgCallable, args: FuncArgs, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

566 }
567
568 fn run_thread(func: ArgCallable, args: FuncArgs, vm: &VirtualMachine) {
569 // Increment thread count when thread actually starts executing
570 vm.state.thread_count.fetch_add(1);
571
572 match func.invoke(args, vm) {
573 Ok(_obj) => {}
574 Err(e) if e.fast_isinstance(vm.ctx.exceptions.system_exit) => {}
575 Err(exc) => {
576 vm.run_unraisable(
577 exc,
578 Some("Exception ignored in thread started by".to_owned()),
579 func.into(),
580 );
581 }
582 }
583 for lock in SENTINELS.take() {
584 if lock.mu.is_locked() {
585 unsafe { lock.mu.unlock() };
586 }
587 }
588 // Clean up thread-local storage while VM context is still active
589 // This ensures __del__ methods are called properly
590 cleanup_thread_local_data();
591 // Clean up frame tracking
592 crate::vm::thread::cleanup_current_thread_frames(vm);
593 vm.state.thread_count.fetch_sub(1);
594 }
595
596 /// Clean up thread-local data for the current thread.
597 /// This triggers __del__ on objects stored in thread-local variables.

Callers 2

start_new_threadFunction · 0.85

Calls 10

fast_isinstanceMethod · 0.80
run_unraisableMethod · 0.80
is_lockedMethod · 0.80
SomeClass · 0.50
invokeMethod · 0.45
to_ownedMethod · 0.45
takeMethod · 0.45
unlockMethod · 0.45

Tested by 1