code: def _acquire_lock(lock_manager: ConsulLockManager, configuration: CliLockConfiguration) \
          -> Optional[ConnectedConsulLockInformation]:
      
      event_listeners: LockEventListener = {}
      if configuration.on_before_locked_executables is not None:
          event_listeners["on_before_lock"] = _generate_event_listener_caller(
              configuration.on_before_locked_executables)
      if configuration.on_lock_already_locked_executables is not None:
          event_listeners["on_lock_already_locked"] = _generate_event_listener_caller(
              configuration.on_lock_already_locked_executables)
  
      try:
          return lock_manager.acquire(
              key=configuration.key, blocking=not configuration.non_blocking,
              timeout=configuration.timeout, metadata=configuration.metadata, **event_listeners,
              lock_poll_interval_generator=lambda i: configuration.lock_poll_interval)
      except LockAcquireTimeoutError as e:
          logger.debug(e)
          logger.error(f"Timed out whilst waiting to acquire lock: {configuration.key}")
          print(json.dumps(None))
          exit(LOCK_ACQUIRE_TIMEOUT_EXIT_CODE)
docs: TODO
      :param lock_manager:
      :param configuration:
      :return: