def test_close_sync(client): sem = Semaphore() sem.close() with pytest.raises(RuntimeError, match="Semaphore .* not known or already closed."): sem.acquire()
def f(x, release=True): sem = Semaphore(name="x") if not sem.acquire(timeout=0.1): return False if release: assert sem.release() is True return True
def test_timeout_sync(client): s = Semaphore(name="x") # Using the context manager already acquires a lease, so the line below won't be able to acquire another one with s: assert s.acquire(timeout=0.025) is False