def obtain_lock_id_to_hog():
    """
    Finds a free id, locks it and returns integer id, or -1 if none free.

    * Lock must be freed manually *
    """
    for id in board_ids():
        if _obtain_lock(id):
            return id
    return -1

    Finds a free id, locks it and returns integer id, or -1 if none free.

    * Lock must be freed manually *
    
cudamat/gpu_lock.py