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

Function is_coroutine

crates/stdlib/src/_asyncio.rs:2704–2718  ·  view source on GitHub ↗
(obj: PyObjectRef, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

2702 }
2703
2704 fn is_coroutine(obj: PyObjectRef, vm: &VirtualMachine) -> PyResult<bool> {
2705 if obj.class().is(vm.ctx.types.coroutine_type) {
2706 return Ok(true);
2707 }
2708
2709 let asyncio_coroutines = vm.import("asyncio.coroutines", 0)?;
2710 if let Some(iscoroutine) =
2711 vm.get_attribute_opt(asyncio_coroutines, vm.ctx.intern_str("iscoroutine"))?
2712 {
2713 let result = iscoroutine.call((obj,), vm)?;
2714 result.try_to_bool(vm)
2715 } else {
2716 Ok(false)
2717 }
2718 }
2719
2720 fn new_invalid_state_error(vm: &VirtualMachine, msg: &str) -> PyBaseExceptionRef {
2721 match vm.import("asyncio.exceptions", 0) {

Callers 1

py_initMethod · 0.85

Calls 7

isMethod · 0.80
get_attribute_optMethod · 0.80
intern_strMethod · 0.80
try_to_boolMethod · 0.80
classMethod · 0.45
importMethod · 0.45
callMethod · 0.45

Tested by

no test coverage detected