Example #1
0
def test_lock_twice_with_unlock(lock_dir_path, key_path, lock_type):
    exclusive = LOCK_TYPES[lock_type]
    assert dirlock.trylock(
        path=lock_dir_path, excl=exclusive, key_path=key_path
    )
    unlock(lock_dir_path, key_path)
    assert dirlock.trylock(
        path=lock_dir_path, excl=exclusive, key_path=key_path
    )
Example #2
0
def test_lock_twice_with_unlock(lock_dir_path, key_path, lock_type):
    exclusive = LOCK_TYPES[lock_type]
    assert dirlock.trylock(
        path=lock_dir_path,
        excl=exclusive, key_path=key_path
    )
    unlock(lock_dir_path, key_path)
    assert dirlock.trylock(
        path=lock_dir_path,
        excl=exclusive, key_path=key_path
    )
Example #3
0
def test_lock_twice(lock_dir_path, key_path, lock_type):
    exclusive = LOCK_TYPES[lock_type]
    assert dirlock.trylock(
        path=lock_dir_path, excl=exclusive, key_path=key_path
    )
    if exclusive:
        assert not dirlock.trylock(
            path=lock_dir_path, excl=exclusive, key_path=key_path
        )
    else:
        assert dirlock.trylock(
            path=lock_dir_path, excl=exclusive, key_path=key_path
        )
Example #4
0
def test_lock_twice(lock_dir_path, key_path, lock_type):
    exclusive = LOCK_TYPES[lock_type]
    assert dirlock.trylock(
        path=lock_dir_path,
        excl=exclusive, key_path=key_path
    )
    if exclusive:
        assert not dirlock.trylock(
            path=lock_dir_path,
            excl=exclusive,
            key_path=key_path
        )
    else:
        assert dirlock.trylock(
            path=lock_dir_path,
            excl=exclusive,
            key_path=key_path
        )
Example #5
0
def test_lock_once(lock_dir_path, key_path, lock_type):
    assert dirlock.trylock(
        path=lock_dir_path,
        excl=LOCK_TYPES[lock_type],
        key_path=key_path
    )
Example #6
0
def trylock_exclusive(lock_dir_path, key_path):
    return dirlock.trylock(lock_dir_path, True, key_path)
Example #7
0
if __name__ == '__main__':
    logging.basicConfig(
        stream=sys.stdout,
        level=logging.DEBUG,
        format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
    )

    optlist, args = getopt.gnu_getopt(sys.argv[1:], '', ['create='])

    templates_dir = args[0]
    create_url = None
    for opt, arg in optlist:
        if opt == '--create':
            create_url = arg

    if create_url:
        initialize(templates_dir, create_url)

    fd, temp_path = tempfile.mkstemp()
    os.write(fd, uuid.uuid1().hex)
    os.close(fd)
    try:
        if dirlock.trylock(templates_dir, True, temp_path):
            logging.info('Successfully locked templates directory')
            update(templates_dir)
        else:
            logging.info('Skipping templates update, templates in use')
    finally:
        os.unlink(temp_path)
Example #8
0
def test_lock_once(lock_dir_path, key_path, lock_type):
    assert dirlock.trylock(
        path=lock_dir_path,
        excl=LOCK_TYPES[lock_type],
        key_path=key_path
    )
Example #9
0
def trylock_exclusive(lock_dir_path, key_path):
    return dirlock.trylock(lock_dir_path, True, key_path)
Example #10
0
def trylock_uuid(testdir, excl):
    return dirlock.trylock(testdir, excl, prefix.paths.uuid())