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

Method py_init

crates/stdlib/src/_asyncio.rs:187–216  ·  view source on GitHub ↗
(
            zelf: &PyRef<Self>,
            loop_: Option<PyObjectRef>,
            vm: &VirtualMachine,
        )

Source from the content-addressed store, hash-verified

185 }
186
187 fn py_init(
188 zelf: &PyRef<Self>,
189 loop_: Option<PyObjectRef>,
190 vm: &VirtualMachine,
191 ) -> PyResult<()> {
192 // Get the event loop
193 let loop_obj = match loop_ {
194 Some(l) if !vm.is_none(&l) => l,
195 _ => get_event_loop(vm)?,
196 };
197 *zelf.fut_loop.write() = Some(loop_obj.clone());
198
199 // Check if loop has get_debug method and call it
200 if let Ok(Some(get_debug)) =
201 vm.get_attribute_opt(loop_obj.clone(), vm.ctx.intern_str("get_debug"))
202 && let Ok(debug) = get_debug.call((), vm)
203 && debug.try_to_bool(vm).unwrap_or(false)
204 {
205 // Get source traceback
206 if let Ok(tb_module) = vm.import("traceback", 0)
207 && let Ok(Some(extract_stack)) =
208 vm.get_attribute_opt(tb_module, vm.ctx.intern_str("extract_stack"))
209 && let Ok(tb) = extract_stack.call((), vm)
210 {
211 *zelf.fut_source_tb.write() = Some(tb);
212 }
213 }
214
215 Ok(())
216 }
217
218 #[pymethod]
219 fn result(&self, vm: &VirtualMachine) -> PyResult {

Callers

nothing calls this directly

Calls 15

is_coroutineFunction · 0.85
get_copy_contextFunction · 0.85
task_eager_startFunction · 0.85
newFunction · 0.85
get_attribute_optMethod · 0.80
intern_strMethod · 0.80
try_to_boolMethod · 0.80
fast_isinstanceMethod · 0.80
is_trueMethod · 0.80
get_event_loopFunction · 0.70
get_running_loopFunction · 0.70
_register_taskFunction · 0.70

Tested by

no test coverage detected