@gen.engine
def RunOnce(client, job, callback):
  assert not options.options.require_lock or job.HasLock() == True
  checker = DatabaseChecker(client, repair=options.options.repair)

  last_scan = None
  if options.options.smart_scan:
    # Search for successful full-scan run in the last week.
    last_run = yield gen.Task(job.FindLastSuccess, with_payload_key='stats.full_scan', with_payload_value=True)

    if last_run is None:
      logging.info('No successful run found in the last week; performing full scan.')
    else:
      # Make sure enough time has passed since the last run.
      last_run_start = last_run['start_time']
      if util.HoursSince(last_run_start) < options.options.hours_between_runs:
        logging.info('Last successful run started at %s, less than %d hours ago; skipping.' %
                     (time.asctime(time.localtime(last_run_start)), options.options.hours_between_runs))
        callback()
        return

      # Set scan_start to start of previous run - 1h (dbchk does not scan viewpoints updated in the last hour).
      last_scan = last_run_start - _CHECK_THRESHOLD_TIMESPAN
      # We intentionally log local times to avoid confusion.
      logging.info('Last successful DBCHK run was at %s, scanning viewpoints updated after %s' %
                   (time.asctime(time.localtime(last_run_start)), time.asctime(time.localtime(last_scan))))

  job.Start()
  try:
    if options.options.viewpoints:
      yield gen.Task(checker.CheckViewpointList, options.options.viewpoints)
    else:
      yield gen.Task(checker.CheckAllViewpoints, last_scan=last_scan)
  except:
    # Failure: log run summary with trace.
    typ, val, tb = sys.exc_info()
    msg = 'Error while visiting viewpoint=%s or user=%s\n' % (checker._current_viewpoint, checker._current_user)
    msg += ''.join(traceback.format_exception(typ, val, tb))
    logging.info('Registering failed run with message: %s' % msg)
    yield gen.Task(job.RegisterRun, Job.STATUS_FAILURE, failure_msg=msg)
  else:
    # Successful: write run summary.
    stats = DotDict()
    stats['full_scan'] = len(options.options.viewpoints) == 0
    stats['dbchk.visited_viewpoints'] = checker._num_visited_viewpoints
    logging.info('Registering successful run with stats: %r' % stats)
    yield gen.Task(job.RegisterRun, Job.STATUS_SUCCESS, stats=stats)

  callback()
Helper function. Makes sure an accessing object is a player object
dataset/ETHPy150Open viewfinderco/viewfinder/backend/db/tools/dbchk.py/RunOnce--crossover with--dataset/ETHPy150Open evennia/evennia/evennia/locks/lockfuncs.py/_to_player