def obtain_lock_id(pid=None):
    id = -1
    id = obtain_lock_id_to_hog()
    try:
        if id >= 0:
            if pid is None:
                pid = os.getpid()
            _launch_reaper(id, pid)
    except:
        free_lock(id)
        id = -1
    return id
Finds a free id, locks it and returns integer id, or -1 if none free.
dataset/ETHPy150Open nitishsrivastava/deepnet/cudamat/gpu_lock2.py/obtain_lock_id