mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 10:44:36 +08:00
Accept keyword arguments in SemLock constructors (#9188)
Assisted-by: Codex:GPT-6
This commit is contained in:
1 parent
e792ec8fb3
commit
7750dbcb86
2 files changed
+22
-10
No files matched your search
@@ -115,15 +115,15 @@ mod _multiprocessing {
|
||||
|
||||
#[derive(FromArgs)]
|
||||
struct SemLockNewArgs {
|
||||
#[pyarg(positional)]
|
||||
#[pyarg(any)]
|
||||
kind: i32,
|
||||
#[pyarg(positional)]
|
||||
#[pyarg(any)]
|
||||
value: i32,
|
||||
#[pyarg(positional)]
|
||||
#[pyarg(any)]
|
||||
maxvalue: i32,
|
||||
#[pyarg(positional)]
|
||||
#[pyarg(any)]
|
||||
name: String,
|
||||
#[pyarg(positional)]
|
||||
#[pyarg(any)]
|
||||
unlink: bool,
|
||||
}
|
||||
|
||||
@@ -515,15 +515,15 @@ mod _multiprocessing {
|
||||
|
||||
#[derive(FromArgs)]
|
||||
struct SemLockNewArgs {
|
||||
#[pyarg(positional)]
|
||||
#[pyarg(any)]
|
||||
kind: i32,
|
||||
#[pyarg(positional)]
|
||||
#[pyarg(any)]
|
||||
value: i32,
|
||||
#[pyarg(positional)]
|
||||
#[pyarg(any)]
|
||||
maxvalue: i32,
|
||||
#[pyarg(positional)]
|
||||
#[pyarg(any)]
|
||||
name: String,
|
||||
#[pyarg(positional)]
|
||||
#[pyarg(any)]
|
||||
unlink: bool,
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
import multiprocessing
|
||||
import threading
|
||||
from _multiprocessing import SemLock
|
||||
|
||||
|
||||
def wait_on_condition(cond, started, woken):
|
||||
@@ -80,6 +81,17 @@ def notify_one_then_the_other(ctx):
|
||||
|
||||
if __name__ == "__main__":
|
||||
multiprocessing.freeze_support()
|
||||
# Low-level callers can supply every constructor parameter by name.
|
||||
name = f"/rustpython_kw_{multiprocessing.current_process().pid}"
|
||||
for args, kwargs in (
|
||||
((1, 1, 1), {"name": name, "unlink": True}),
|
||||
((), {"kind": 1, "value": 1, "maxvalue": 1, "name": name, "unlink": True}),
|
||||
):
|
||||
sem = SemLock(*args, **kwargs)
|
||||
assert sem.acquire(False)
|
||||
assert not sem.acquire(False)
|
||||
sem.release()
|
||||
del sem
|
||||
methods = ["spawn"]
|
||||
if "forkserver" in multiprocessing.get_all_start_methods():
|
||||
methods.append("forkserver")
|
||||
|
||||
Reference in new issue
Block a user