Пример #1
0
def test():

    # Create a Lock
    lock = Lock("test")

    # Should not be yet held.
    assert lock.held() == False

    # Go get it
    lock.acquire()

    # Second lock shall throw in debug mode.
    try:
        lock.acquire()
    except AssertionError, e:
        if str(e) != flock.WriteLock.ERROR_ISLOCKED:
            raise
Пример #2
0
def test():

    # Create a Lock
    lock = Lock("test")

    # Should not be yet held.
    assert lock.held() == False

    # Go get it
    lock.acquire()

    # Second lock shall throw in debug mode.
    try:
        lock.acquire()
    except AssertionError as e:
        if str(e) != flock.WriteLock.ERROR_ISLOCKED:
            raise
    else:
        raise AssertionError("Reaquired a locked lock")

    lock.release()

    Lock.cleanup()