'Acquire the lock if possible.
If the lock is in use and ``blocking`` is ``False``, return
``False``.
Otherwise, check every `self.delay` seconds until it acquires
lock or exceeds `self.timeout` and raises an exception.'

def acquire(self, blocking=True):

    start = time.time()
    while True:
        try:
            fd = os.open(self.lockfile, ((os.O_CREAT | os.O_EXCL) | os.O_RDWR))
            with os.fdopen(fd, u'w') as fd:
                fd.write(u'{0}'.format(os.getpid()))
            break
        except OSError as err:
            if (err.errno != errno.EEXIST):
                raise
            if (self.timeout and ((time.time() - start) >= self.timeout)):
                raise AcquisitionError(u'Lock    acquisition    timed    out.')
            if (not blocking):
                return False
            time.sleep(self.delay)
    self._locked = True
    return True
