import fcntl


def lockFile(lockfile):
    """Attempt to create lock file or fail if already locked"""
    fp = open(lockfile, 'w')
    try:
        fcntl.lockf(fp, fcntl.LOCK_EX | fcntl.LOCK_NB)
    except IOError:
        return False
    return True