docs: def LeaseCronJobs(self, cronjob_ids=None, lease_time=None, cursor=None):
      """Leases all available cron jobs."""
      now = rdfvalue.RDFDatetime.Now()
      now_str = mysql_utils.RDFDatetimeToTimestamp(now)
      expiry_str = mysql_utils.RDFDatetimeToTimestamp(now + lease_time)
      id_str = utils.ProcessIdString()
  
      query = ("UPDATE cron_jobs "
               "SET leased_until=FROM_UNIXTIME(%s), leased_by=%s "
               "WHERE (leased_until IS NULL OR leased_until < FROM_UNIXTIME(%s))")
      args = [expiry_str, id_str, now_str]
  
      if cronjob_ids:
        query += " AND job_id in (%s)" % ", ".join(["%s"] * len(cronjob_ids))
        args += cronjob_ids
  
      updated = cursor.execute(query, args)
  
      if updated == 0:
        return []
  
      cursor.execute(
          "SELECT job, UNIX_TIMESTAMP(create_time), enabled,"
          "forced_run_requested, last_run_status, UNIX_TIMESTAMP(last_run_time), "
          "current_run_id, state, UNIX_TIMESTAMP(leased_until), leased_by "
          "FROM cron_jobs "
          "FORCE INDEX (cron_jobs_by_lease) "
          "WHERE leased_until=FROM_UNIXTIME(%s) AND leased_by=%s",
          [expiry_str, id_str])
      return [self._CronJobFromRow(row) for row in cursor.fetchall()]