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

Method sock_wait_for_io_impl

crates/stdlib/src/ssl.rs:2589–2620  ·  view source on GitHub ↗

Internal implementation with timeout control

(
            &self,
            kind: SelectKind,
            vm: &VirtualMachine,
        )

Source from the content-addressed store, hash-verified

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(

Callers 4

send_tls_outputMethod · 0.80
send_all_bytesFunction · 0.80
handshake_read_dataFunction · 0.80

Calls 8

sock_selectFunction · 0.85
is_bio_modeMethod · 0.80
get_socket_timeoutMethod · 0.80
try_into_valueMethod · 0.80
sockMethod · 0.80
new_os_errorMethod · 0.80
is_zeroMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected