def __init__(self, store, subject, lease_time=None, token=None):
    super(MySQLTransaction, self).__init__(store, 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()
    self.lock_time = lease_time
    self.expires_lock = int((time.time() + self.lock_time) * 1e6)

    # This will take over the lock if the lock is too old.
    query = (
        "UPDATE locks SET lock_expiration=%s, lock_owner=%s "
        "WHERE subject_hash=unhex(md5(%s)) "
        "AND (lock_expiration < %s)")
    args = [self.expires_lock, self.lock_token, subject, time.time() * 1e6]
    self.store.ExecuteQuery(query, args)

    self._CheckForLock()
Ensure we can take a lock on this subject.
dataset/ETHPy150Open google/grr/grr/lib/data_stores/mysql_advanced_data_store.py/MySQLTransaction.__init__