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

Method run

crates/vm/src/vm/thread.rs:555–561  ·  view source on GitHub ↗

Run a function in this thread context # Note If you return a `PyObjectRef` (or a type that contains one) from `F`, and don't return the object to the parent thread and then `join()` on the `JoinHandle` (or similar), there is a possibility that the current thread will panic as `PyObjectRef`'s `Drop` implementation tries to run the `__del__` destructor of a python object but finds that it's not in

(&self, f: F)

Source from the content-addressed store, hash-verified

553 /// the current thread will panic as `PyObjectRef`'s `Drop` implementation tries to run the `__del__`
554 /// destructor of a python object but finds that it's not in the context of any vm.
555 pub fn run<F, R>(&self, f: F) -> R
556 where
557 F: FnOnce(&VirtualMachine) -> R,
558 {
559 let vm = &self.vm;
560 enter_vm(vm, || f(vm))
561 }
562}
563
564impl VirtualMachine {

Callers 2

make_spawn_funcMethod · 0.45
run_frameMethod · 0.45

Calls 2

enter_vmFunction · 0.85
fFunction · 0.50

Tested by

no test coverage detected