@gen.engine
def _Start(callback):
 client = db_client.DBClient.Instance()
 job = Job(client, 'analyze_analytics')
 if options.options.require_lock:
  got_lock = (yield gen.Task(job.AcquireLock))
  if (got_lock == False):
   logging.warning('Failed to acquire job lock: exiting.')
   callback()
   return
 result = None
 job.Start()
 try:
  result = (yield gen.Task(RunOnce, client, job))
 except:
  (typ, val, tb) = sys.exc_info()
  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:
  if ((result is not None) and (not options.options.dry_run)):
   stats = DotDict()
   stats['last_day'] = result
   logging.info(('Registering successful run with stats: %r' % stats))
   (yield gen.Task(job.RegisterRun, Job.STATUS_SUCCESS, stats=stats))
 finally:
  (yield gen.Task(job.ReleaseLock))
 callback()

@ gen . engine def _Start ( callback ) : client = db_client . DBClient . Instance ( ) job = Job ( client , 'analyze_analytics' ) if options . options . require_lock : got_lock = ( yield gen . Task ( job . AcquireLock ) ) if ( got_lock == False ) : logging . warning ( 'Failed to acquire job lock: exiting.' ) callback ( ) return result = None job . Start ( ) try : result = ( yield gen . Task ( RunOnce , client , job ) ) except : ( typ , val , tb ) = sys . exc_info ( ) 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 : if ( ( result is not None ) and ( not options . options . dry_run ) ) : stats = DotDict ( ) stats [ 'last_day' ] = result logging . info ( ( 'Registering successful run with stats: %r' % stats ) ) ( yield gen . Task ( job . RegisterRun , Job . STATUS_SUCCESS , stats = stats ) ) finally : ( yield gen . Task ( job . ReleaseLock ) ) callback ( )
grab the job lock and call runonce if acquired .