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

Method cancel

crates/stdlib/src/overlapped.rs:443–463  ·  view source on GitHub ↗
(zelf: &Py<Self>, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

441
442 #[pymethod]
443 fn cancel(zelf: &Py<Self>, vm: &VirtualMachine) -> PyResult<()> {
444 let inner = zelf.inner.lock();
445 if matches!(
446 inner.data,
447 OverlappedData::NotStarted | OverlappedData::WaitNamedPipeAndConnect
448 ) {
449 return Ok(());
450 }
451 let ret = if !HasOverlappedIoCompleted(&inner.overlapped) {
452 unsafe {
453 windows_sys::Win32::System::IO::CancelIoEx(inner.handle, &inner.overlapped)
454 }
455 } else {
456 1
457 };
458 // CancelIoEx returns ERROR_NOT_FOUND if the I/O completed in-between
459 if ret == 0 && unsafe { GetLastError() } != Foundation::ERROR_NOT_FOUND {
460 return Err(set_from_windows_err(0, vm));
461 }
462 Ok(())
463 }
464
465 #[pymethod]
466 fn getresult(zelf: &Py<Self>, wait: OptionalArg<bool>, vm: &VirtualMachine) -> PyResult {

Callers

nothing calls this directly

Calls 5

HasOverlappedIoCompletedFunction · 0.85
set_from_windows_errFunction · 0.85
GetLastErrorFunction · 0.50
ErrClass · 0.50
lockMethod · 0.45

Tested by

no test coverage detected