Merge pull request #1344 from youknowone/thread-timeout

_thread.TIMEOUT_MAX
This commit is contained in:
Windel Bouwman
2019-10-06 14:06:41 +02:00
committed by GitHub
2 changed files with 12 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
import _thread
assert _thread.TIMEOUT_MAX in [9223372036.0, 4294967.0]

View File

@@ -5,6 +5,14 @@ use crate::function::PyFuncArgs;
use crate::pyobject::PyResult;
use crate::vm::VirtualMachine;
#[cfg(not(target_os = "windows"))]
const PY_TIMEOUT_MAX: isize = std::isize::MAX;
#[cfg(target_os = "windows")]
const PY_TIMEOUT_MAX: isize = 0xffffffff * 1_000_000;
const TIMEOUT_MAX: f64 = (PY_TIMEOUT_MAX / 1_000_000_000) as f64;
fn rlock_acquire(vm: &VirtualMachine, _args: PyFuncArgs) -> PyResult {
Ok(vm.get_none())
}
@@ -54,5 +62,6 @@ pub fn make_module(vm: &VirtualMachine) -> PyObjectRef {
"RLock" => rlock_type,
"get_ident" => ctx.new_rustfunc(get_ident),
"allocate_lock" => ctx.new_rustfunc(allocate_lock),
"TIMEOUT_MAX" => ctx.new_float(TIMEOUT_MAX),
})
}