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

Function setdefaulttimeout

crates/stdlib/src/socket.rs:3403–3419  ·  view source on GitHub ↗
(timeout: Option<ArgIntoFloat>, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

3401
3402 #[pyfunction]
3403 fn setdefaulttimeout(timeout: Option<ArgIntoFloat>, vm: &VirtualMachine) -> PyResult<()> {
3404 let val = match timeout {
3405 Some(t) => {
3406 let f = t.into_float();
3407 if f.is_nan() {
3408 return Err(vm.new_value_error("Invalid value NaN (not a number)"));
3409 }
3410 if f < 0.0 || !f.is_finite() {
3411 return Err(vm.new_value_error("Timeout value out of range"));
3412 }
3413 f
3414 }
3415 None => -1.0,
3416 };
3417 DEFAULT_TIMEOUT.store(val);
3418 Ok(())
3419 }
3420
3421 #[pyfunction]
3422 fn dup(x: PyObjectRef, vm: &VirtualMachine) -> Result<RawSocket, IoOrPyException> {

Callers

nothing calls this directly

Calls 5

into_floatMethod · 0.80
ErrClass · 0.50
is_nanMethod · 0.45
is_finiteMethod · 0.45
storeMethod · 0.45

Tested by

no test coverage detected