code: def travis_after(ini, envlist):
      
      # after-all disabled for pull requests
      if os.environ.get('TRAVIS_PULL_REQUEST', 'false') != 'false':
          return
  
      if not after_config_matches(ini, envlist):
          return  # This is not the one that needs to wait
  
      github_token = os.environ.get('GITHUB_TOKEN')
      if not github_token:
          print('No GitHub token given.', file=sys.stderr)
          sys.exit(NO_GITHUB_TOKEN)
  
      api_url = os.environ.get('TRAVIS_API_URL', 'https://api.travis-ci.org')
      build_id = os.environ.get('TRAVIS_BUILD_ID')
      job_number = os.environ.get('TRAVIS_JOB_NUMBER')
  
      try:
          polling_interval = int(os.environ.get('TRAVIS_POLLING_INTERVAL', 5))
      except ValueError:
          print('Invalid polling interval given: {0}'.format(
              repr(os.environ.get('TRAVIS_POLLING_INTERVAL'))), file=sys.stderr)
          sys.exit(INVALID_POLLING_INTERVAL)
  
      if not all([api_url, build_id, job_number]):
          print('Required Travis environment not given.', file=sys.stderr)
          sys.exit(INCOMPLETE_TRAVIS_ENVIRONMENT)
  
      # This may raise an Exception, and it should be printed
      job_statuses = get_job_statuses(
          github_token, api_url, build_id, polling_interval, job_number)
  
      if not all(job_statuses):
          print('Some jobs were not successful.')
          sys.exit(JOBS_FAILED)
  
      print('All required jobs were successful.')
docs: Wait for all jobs to finish, then exit successfully.