(zelf: &Py<Self>, vm: &VirtualMachine)
| 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 { |
nothing calls this directly
no test coverage detected