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

Function _run_exitfuncs

crates/vm/src/stdlib/atexit.rs:69–86  ·  view source on GitHub ↗
(vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

67
68 #[pyfunction]
69 pub fn _run_exitfuncs(vm: &VirtualMachine) {
70 let funcs: Vec<_> = core::mem::take(&mut *vm.state.atexit_funcs.lock());
71 // Callbacks stored in LIFO order, iterate forward
72 for entry in funcs.into_iter() {
73 let (func, args) = *entry;
74 if let Err(e) = func.call(args, vm) {
75 let exit = e.fast_isinstance(vm.ctx.exceptions.system_exit);
76 let msg = func
77 .repr(vm)
78 .ok()
79 .map(|r| format!("Exception ignored in atexit callback {}", r.as_wtf8()));
80 vm.run_unraisable(e, msg, vm.ctx.none());
81 if exit {
82 break;
83 }
84 }
85 }
86 }
87
88 #[pyfunction]
89 fn _ncallbacks(vm: &VirtualMachine) -> usize {

Callers 1

finalizeMethod · 0.85

Calls 10

takeFunction · 0.85
fast_isinstanceMethod · 0.80
okMethod · 0.80
run_unraisableMethod · 0.80
noneMethod · 0.80
lockMethod · 0.45
into_iterMethod · 0.45
callMethod · 0.45
mapMethod · 0.45
reprMethod · 0.45

Tested by

no test coverage detected