(&self, timeout: Option<ArgIntoFloat>, vm: &VirtualMachine)
| 2224 | |
| 2225 | #[pymethod] |
| 2226 | fn settimeout(&self, timeout: Option<ArgIntoFloat>, vm: &VirtualMachine) -> PyResult<()> { |
| 2227 | let timeout = match timeout { |
| 2228 | Some(t) => { |
| 2229 | let f = t.into_float(); |
| 2230 | if f.is_nan() { |
| 2231 | return Err(vm.new_value_error("Invalid value NaN (not a number)")); |
| 2232 | } |
| 2233 | if f < 0.0 || !f.is_finite() { |
| 2234 | return Err(vm.new_value_error("Timeout value out of range")); |
| 2235 | } |
| 2236 | Some(f) |
| 2237 | } |
| 2238 | None => None, |
| 2239 | }; |
| 2240 | self.timeout.store(timeout.unwrap_or(-1.0)); |
| 2241 | // even if timeout is > 0 the socket needs to be nonblocking in order for us to select() on |
| 2242 | // it |
| 2243 | self.sock() |
| 2244 | .map_err(|e| e.into_pyexception(vm))? |
| 2245 | .set_nonblocking(timeout.is_some()) |
| 2246 | .map_err(|e| e.into_pyexception(vm)) |
| 2247 | } |
| 2248 | |
| 2249 | #[pymethod] |
| 2250 | fn getsockopt( |
nothing calls this directly
no test coverage detected