Skip to content

Commit 549c95c

Browse files
Merge pull request #1344 from youknowone/thread-timeout
_thread.TIMEOUT_MAX
2 parents b8582ae + 035c51b commit 549c95c

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

tests/snippets/builtin_thread.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import _thread
2+
3+
assert _thread.TIMEOUT_MAX in [9223372036.0, 4294967.0]

vm/src/stdlib/thread.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ use crate::function::PyFuncArgs;
55
use crate::pyobject::PyResult;
66
use crate::vm::VirtualMachine;
77

8+
#[cfg(not(target_os = "windows"))]
9+
const PY_TIMEOUT_MAX: isize = std::isize::MAX;
10+
11+
#[cfg(target_os = "windows")]
12+
const PY_TIMEOUT_MAX: isize = 0xffffffff * 1_000_000;
13+
14+
const TIMEOUT_MAX: f64 = (PY_TIMEOUT_MAX / 1_000_000_000) as f64;
15+
816
fn rlock_acquire(vm: &VirtualMachine, _args: PyFuncArgs) -> PyResult {
917
Ok(vm.get_none())
1018
}
@@ -54,5 +62,6 @@ pub fn make_module(vm: &VirtualMachine) -> PyObjectRef {
5462
"RLock" => rlock_type,
5563
"get_ident" => ctx.new_rustfunc(get_ident),
5664
"allocate_lock" => ctx.new_rustfunc(allocate_lock),
65+
"TIMEOUT_MAX" => ctx.new_float(TIMEOUT_MAX),
5766
})
5867
}

0 commit comments

Comments
 (0)