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

Method run

crates/vm/src/vm/interpreter.rs:385–391  ·  view source on GitHub ↗

Run a function with the main virtual machine and return exit code. To enter vm context only once and safely terminate the vm, this function is preferred. Unlike [`Interpreter::enter`], `run` calls finalize and returns exit code. You will not be able to obtain Python exception in this way. See [`Interpreter::finalize`] for the finalization steps. See also [`Interpreter::enter`] for pure function

(self, f: F)

Source from the content-addressed store, hash-verified

383 /// See [`Interpreter::finalize`] for the finalization steps.
384 /// See also [`Interpreter::enter`] for pure function call to obtain Python exception.
385 pub fn run<F>(self, f: F) -> u32
386 where
387 F: FnOnce(&VirtualMachine) -> PyResult<()>,
388 {
389 let res = self.enter(|vm| f(vm));
390 self.finalize(res.err())
391 }
392
393 /// Finalize vm and turns an exception to exit code.
394 ///

Callers

nothing calls this directly

Calls 4

errMethod · 0.80
fFunction · 0.50
enterMethod · 0.45
finalizeMethod · 0.45

Tested by

no test coverage detected