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

Method cancel

crates/stdlib/src/_asyncio.rs:462–476  ·  view source on GitHub ↗
(zelf: PyRef<Self>, args: CancelArgs, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

460
461 #[pymethod]
462 fn cancel(zelf: PyRef<Self>, args: CancelArgs, vm: &VirtualMachine) -> PyResult<bool> {
463 if zelf.fut_loop.read().is_none() {
464 return Err(vm.new_runtime_error("Future object is not initialized."));
465 }
466 if zelf.fut_state.load() != FutureState::Pending {
467 // Clear log_tb even when cancel fails
468 zelf.fut_log_tb.store(false, Ordering::Relaxed);
469 return Ok(false);
470 }
471
472 *zelf.fut_cancel_msg.write() = args.msg.flatten();
473 zelf.fut_state.store(FutureState::Cancelled);
474 Self::schedule_callbacks(&zelf, vm)?;
475 Ok(true)
476 }
477
478 #[pymethod]
479 fn cancelled(&self) -> bool {

Callers

nothing calls this directly

Calls 14

newFunction · 0.85
collectMethod · 0.80
try_to_boolMethod · 0.80
ErrClass · 0.50
is_noneMethod · 0.45
readMethod · 0.45
loadMethod · 0.45
storeMethod · 0.45
writeMethod · 0.45
flattenMethod · 0.45
cloneMethod · 0.45
into_iterMethod · 0.45

Tested by

no test coverage detected