def main(argv):

  if not FLAGS.dbspec:
    raise app.UsageError('You must specify a dbspec.')

  dbspec = db.Spec.Parse(FLAGS.dbspec)

  logging.info('Heartbeat starting up...')
  while True:
    # Set a signal so that, no matter what, we guarantee we won't just
    # get stuck.  If we don't make it back to the top of this loop by
    # the time the alarm expires, our process will terminate.
    signal.alarm(FLAGS.connection_lifetime * 2)
    with dbspec.Connect() as dbh:
      # This is likely the default, but if its not, each beat should be a
      # transaction.
      dbh.ExecuteOrDie('SET AUTOCOMMIT=1;')
      DoHeartbeat(dbh, FLAGS.interval, FLAGS.connection_lifetime)
    logging.info("Feelin' fine, reconnecting...")
dataset/ETHPy150Open google/mysql-tools/replication_heartbeat.py/main/original