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

Method init_hooks

crates/vm/src/builtins/asyncgenerator.rs:63–85  ·  view source on GitHub ↗

Initialize async generator hooks. Returns Ok(()) if successful, Err if firstiter hook raised an exception.

(zelf: &Py<Self>, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

61 /// Initialize async generator hooks.
62 /// Returns Ok(()) if successful, Err if firstiter hook raised an exception.
63 fn init_hooks(zelf: &Py<Self>, vm: &VirtualMachine) -> PyResult<()> {
64 // = async_gen_init_hooks
65 if zelf.ag_hooks_inited.load() {
66 return Ok(());
67 }
68
69 zelf.ag_hooks_inited.store(true);
70
71 // Get and store finalizer from VM
72 let finalizer = vm.async_gen_finalizer.borrow().clone();
73 if let Some(finalizer) = finalizer {
74 *zelf.ag_finalizer.lock() = Some(finalizer);
75 }
76
77 // Call firstiter hook
78 let firstiter = vm.async_gen_firstiter.borrow().clone();
79 if let Some(firstiter) = firstiter {
80 let obj: PyObjectRef = zelf.to_owned().into();
81 firstiter.call((obj,), vm)?;
82 }
83
84 Ok(())
85 }
86
87 /// Call finalizer hook if set.
88 fn call_finalizer(zelf: &Py<Self>, vm: &VirtualMachine) {

Callers

nothing calls this directly

Calls 8

SomeClass · 0.50
loadMethod · 0.45
storeMethod · 0.45
cloneMethod · 0.45
borrowMethod · 0.45
lockMethod · 0.45
to_ownedMethod · 0.45
callMethod · 0.45

Tested by

no test coverage detected