app.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:protoc-gen-lua-bin 作者: u0u0 项目源码 文件源码
def really_start(main=None):
  """Initializes flag values, and calls main with non-flag arguments.

  Only non-flag arguments are passed to main().  The return value of main() is
  used as the exit status.

  Args:
    main: Main function to run with the list of non-flag arguments, or None
      so that sys.modules['__main__'].main is to be used.
  """
  argv = RegisterAndParseFlagsWithUsage()

  if main is None:
    main = sys.modules['__main__'].main

  try:
    if FLAGS.run_with_pdb:
      sys.exit(pdb.runcall(main, argv))
    else:
      if FLAGS.run_with_profiling or FLAGS.profile_file:
        # Avoid import overhead since most apps (including performance-sensitive
        # ones) won't be run with profiling.
        import atexit
        if FLAGS.use_cprofile_for_profiling:
          import cProfile as profile
        else:
          import profile
        profiler = profile.Profile()
        if FLAGS.profile_file:
          atexit.register(profiler.dump_stats, FLAGS.profile_file)
        else:
          atexit.register(profiler.print_stats)
        retval = profiler.runcall(main, argv)
        sys.exit(retval)
      else:
        sys.exit(main(argv))
  except UsageError, error:
    usage(shorthelp=1, detailed_error=error, exitcode=error.exitcode)
  except:
    if FLAGS.pdb_post_mortem:
      traceback.print_exc()
      pdb.post_mortem()
    raise
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号