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

Method get_socket_timeout

crates/stdlib/src/ssl.rs:2405–2427  ·  view source on GitHub ↗

Get socket timeout as Duration

(&self, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

2403
2404 // Get socket timeout as Duration
2405 pub(crate) fn get_socket_timeout(&self, vm: &VirtualMachine) -> PyResult<Option<Duration>> {
2406 if self.is_bio_mode() {
2407 return Ok(None);
2408 }
2409
2410 // Get timeout from socket
2411 let timeout_obj = self.sock.get_attr("gettimeout", vm)?.call((), vm)?;
2412
2413 // timeout can be None (blocking), 0.0 (non-blocking), or positive float
2414 if vm.is_none(&timeout_obj) {
2415 // None means blocking forever
2416 Ok(None)
2417 } else {
2418 let timeout_float: f64 = timeout_obj.try_into_value(vm)?;
2419 if timeout_float <= 0.0 {
2420 // 0 means non-blocking
2421 Ok(Some(Duration::from_secs(0)))
2422 } else {
2423 // Positive timeout
2424 Ok(Some(Duration::from_secs_f64(timeout_float)))
2425 }
2426 }
2427 }
2428
2429 // Create and store a session object after successful handshake
2430 fn create_session_after_handshake(&self, vm: &VirtualMachine) -> PyResult<()> {

Callers 7

sock_wait_for_io_implMethod · 0.80
send_tls_outputMethod · 0.80
ssl_readFunction · 0.80
ssl_writeFunction · 0.80

Calls 6

is_bio_modeMethod · 0.80
try_into_valueMethod · 0.80
SomeClass · 0.50
callMethod · 0.45
get_attrMethod · 0.45
is_noneMethod · 0.45

Tested by

no test coverage detected