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)
| 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 | /// |