code: def acquire(self):
          
          retries = [0]
          self._acquire_start_seconds = self._reactor.seconds()
  
          def log_lock_acquired(result):
              self._lock_acquired_seconds = self._reactor.seconds()
              seconds = self._lock_acquired_seconds - self._acquire_start_seconds
              self._log.msg('Acquired lock in {0} seconds'.format(seconds),
                            lock_acquire_time=seconds, **self._log_kwargs)
              return result
  
          def acquire_lock():
              d = self._write_lock()
              d.addCallback(self._read_lock)
              d.addCallback(self._verify_lock)
              if self._log:
                  d.addCallback(log_lock_acquired)
              d.addErrback(lock_not_acquired)
              return d
  
          def lock_not_acquired(failure):
              failure.trap(BusyLockError, NoLockClaimsError)
              retries[0] += 1
              if retries[0] <= self._max_retry:
                  return task.deferLater(self._reactor, self._retry_wait, acquire_lock)
              else:
                  return failure
  
          def log_lock_acquire_failure(failure):
              if self._log:
                  seconds = self._reactor.seconds() - self._acquire_start_seconds
                  self._log.msg(
                      'Could not acquire lock in {0} seconds due to {1}'.format(seconds, failure),
                      lock_acquire_fail_time=seconds, reason=failure, **self._log_kwargs)
              return failure
  
          return acquire_lock().addErrback(log_lock_acquire_failure)
docs: Acquire the lock.
  
          If the lock can't be acquired immediately, retry a specified number of
          times, with a specified wait time.