Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions crates/stdlib/src/multiprocessing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand Down Expand Up @@ -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,
}

Expand Down
12 changes: 12 additions & 0 deletions extra_tests/snippets/stdlib_multiprocessing_condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import multiprocessing
import threading
from _multiprocessing import SemLock


def wait_on_condition(cond, started, woken):
Expand Down Expand Up @@ -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")
Expand Down
Loading