def __init__(self, store, subject, lease_time=None, token=None):
    """Ensure we can take a lock on this subject."""
    super(SqliteTransaction, self).__init__(store, utils.SmartUnicode(subject),
                                            lease_time=lease_time, token=token)

    if lease_time is None:
      lease_time = config_lib.CONFIG["Datastore.transaction_timeout"]

    self.lock_token = thread.get_ident()
    sqlite_connection = store.cache.Get(self.subject)

    # We first check if there is a lock on the subject.
    # Next we set our lease time and lock_token as identification.
    with sqlite_connection:
      locked_until, stored_token = sqlite_connection.GetLock(subject)

      # This is currently locked by another thread.
      if locked_until and time.time() < float(locked_until):
        raise data_store.TransactionError("Subject %s is locked" % subject)

      # Subject is not locked, we take a lease on it.
      self.expires = time.time() + lease_time
      sqlite_connection.SetLock(subject, self.expires, self.lock_token)

    # Check if the lock stuck. If the stored token is not ours
    # then probably someone was able to grab it before us.
    locked_until, stored_token = sqlite_connection.GetLock(subject)
    if stored_token != self.lock_token:
      raise data_store.TransactionError(subject % "Unable to lock subject %s")

    self.locked = True
dataset/ETHPy150Open google/grr/grr/lib/data_stores/sqlite_data_store.py/SqliteTransaction.__init__/swapped operands of `%`