def get_lock (name, debug=False):
    """Get a new lock.
    @param debug: if True, acquire() and release() will have debug messages
    @ptype debug: boolean, default is False
    @return: a lock object
    @rtype: threading.Lock or DebugLock
    """
    lock = threading.Lock()
    # for thread debugging, use the DebugLock wrapper
    if debug:
        lock = DebugLock(lock, name)
    return lock