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

Method call_soon_with_context

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

Source from the content-addressed store, hash-verified

552 }
553
554 fn call_soon_with_context(
555 zelf: &PyRef<Self>,
556 callback: PyObjectRef,
557 context: Option<PyObjectRef>,
558 vm: &VirtualMachine,
559 ) -> PyResult<()> {
560 let loop_obj = zelf.fut_loop.read().clone();
561 if let Some(loop_obj) = loop_obj {
562 // call_soon(callback, *args, context=context)
563 // callback receives the future as its argument
564 let future_arg: PyObjectRef = zelf.clone().into();
565 let args = if let Some(ctx) = context {
566 FuncArgs::new(
567 vec![callback, future_arg],
568 KwArgs::new([("context".to_owned(), ctx)].into_iter().collect()),
569 )
570 } else {
571 FuncArgs::new(vec![callback, future_arg], KwArgs::default())
572 };
573 vm.call_method(&loop_obj, "call_soon", args)?;
574 }
575 Ok(())
576 }
577
578 // Properties
579 #[pygetset]

Callers

nothing calls this directly

Calls 7

newFunction · 0.85
collectMethod · 0.80
cloneMethod · 0.45
readMethod · 0.45
into_iterMethod · 0.45
to_ownedMethod · 0.45
call_methodMethod · 0.45

Tested by

no test coverage detected