def attempt_acquire(self, timeout, end_time, wait):
        try:
            os.mkdir(self.lock_file)
        except OSError:
            err = sys.exc_info()[1]
            if err.errno == errno.EEXIST:
                # Already locked.
                if os.path.exists(self.unique_name):
                    # Already locked by me.
                    return
                if timeout is not None and time.time() > end_time:
                    if timeout > 0:
                        raise LockTimeout
                    else:
                        # Someone else has the lock.
                        raise AlreadyLocked
                time.sleep(wait)
            else:
                # Couldn"t create the lock for some other reason
                raise LockFailed("failed to create %s" % self.lock_file)
        else:
            open(self.unique_name, "wb").close()
            return
dataset/ETHPy150Open haystack/eyebrowse-server/notifications/lockfile.py/MkdirFileLock.attempt_acquire/original