code: def CreateWithLock(self,
                       urn,
                       aff4_type,
                       token=None,
                       age=NEWEST_TIME,
                       force_new_version=True,
                       blocking=True,
                       blocking_lock_timeout=10,
                       blocking_sleep_interval=1,
                       lease_time=100):
      
  
      if not data_store.AFF4Enabled():
        raise NotImplementedError("AFF4 data store has been disabled.")
  
      transaction = self._AcquireLock(
          urn,
          blocking=blocking,
          blocking_lock_timeout=blocking_lock_timeout,
          blocking_sleep_interval=blocking_sleep_interval,
          lease_time=lease_time)
  
      # Since we now own the data store subject, we can simply create the aff4
      # object in the usual way.
      return self.Create(
          urn,
          aff4_type,
          mode="rw",
          token=token,
          age=age,
          force_new_version=force_new_version,
          transaction=transaction)
docs: Creates a new object and locks it.
  
      Similar to OpenWithLock below, this creates a locked object. The difference
      is that when you call CreateWithLock, the object does not yet have to exist
      in the data store.
  
      Args:
        urn: The object to create.
        aff4_type: The desired type for this object.
        token: The Security Token to use for opening this item.
        age: The age policy used to build this object. Only makes sense when mode
          has "r".
        force_new_version: Forces the creation of a new object in the data_store.
        blocking: When True, wait and repeatedly try to grab the lock.
        blocking_lock_timeout: Maximum wait time when sync is True.
        blocking_sleep_interval: Sleep time between lock grabbing attempts. Used
          when blocking is True.
        lease_time: Maximum time the object stays locked. Lock will be considered
          released when this time expires.
  
      Returns:
        An AFF4 object of the desired type and mode.
  
      Raises:
        AttributeError: If the mode is invalid.