'Acquire the lock, if possible. If the lock is in use, it check again
every `wait` seconds. It does this until it either gets the lock or
exceeds `timeout` number of seconds, in which case it throws
an exception.'

def acquire(self):

    start_time = time.time()
    while True:
        try:
            self.fd = os.open(self.lockfile, ((os.O_CREAT | os.O_EXCL) | os.O_RDWR))
            break
        except OSError as e:
            if (e.errno != errno.EEXIST):
                raise
            if ((time.time() - start_time) >= self.timeout):
                raise FileLockException('Timeout    occured.')
            time.sleep(self.delay)
    self.is_locked = True
