Internal implementation with timeout control
(
&self,
kind: SelectKind,
vm: &VirtualMachine,
)
| 2587 | |
| 2588 | // Internal implementation with timeout control |
| 2589 | pub(crate) fn sock_wait_for_io_impl( |
| 2590 | &self, |
| 2591 | kind: SelectKind, |
| 2592 | vm: &VirtualMachine, |
| 2593 | ) -> PyResult<bool> { |
| 2594 | if self.is_bio_mode() { |
| 2595 | // BIO mode doesn't use select |
| 2596 | return Ok(false); |
| 2597 | } |
| 2598 | |
| 2599 | // Get timeout |
| 2600 | let timeout = self.get_socket_timeout(vm)?; |
| 2601 | |
| 2602 | // Check for non-blocking mode (timeout = 0) |
| 2603 | if let Some(t) = timeout |
| 2604 | && t.is_zero() |
| 2605 | { |
| 2606 | // Non-blocking mode - don't use select |
| 2607 | return Ok(false); |
| 2608 | } |
| 2609 | |
| 2610 | // Use select with the effective timeout |
| 2611 | let py_socket: PyRef<PySocket> = self.sock.clone().try_into_value(vm)?; |
| 2612 | let socket = py_socket |
| 2613 | .sock() |
| 2614 | .map_err(|e| vm.new_os_error(format!("Failed to get socket: {e}")))?; |
| 2615 | |
| 2616 | let timed_out = sock_select(&socket, kind, timeout) |
| 2617 | .map_err(|e| vm.new_os_error(format!("select failed: {e}")))?; |
| 2618 | |
| 2619 | Ok(timed_out) |
| 2620 | } |
| 2621 | |
| 2622 | // Internal implementation with explicit timeout override |
| 2623 | pub(crate) fn sock_wait_for_io_with_timeout( |
no test coverage detected