示例#1
0
def test_close_sync(client):
    sem = Semaphore()
    sem.close()

    with pytest.raises(RuntimeError,
                       match="Semaphore .* not known or already closed."):
        sem.acquire()
示例#2
0
    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
示例#3
0
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