Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5548)

Unified Diff: chrome/common/extensions/docs/server2/cron_servlet.py

Issue 23081003: Docserver move cron jobs to a backend instance Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/docs/server2/cron_servlet.py
diff --git a/chrome/common/extensions/docs/server2/cron_servlet.py b/chrome/common/extensions/docs/server2/cron_servlet.py
index 15cd3d3c1a4fbe9762c5a695a29361bddf8a12af..4c7b75f6e9c34b14e933f87e585554fcfe7ddb33 100644
--- a/chrome/common/extensions/docs/server2/cron_servlet.py
+++ b/chrome/common/extensions/docs/server2/cron_servlet.py
@@ -8,7 +8,7 @@ import traceback
from app_yaml_helper import AppYamlHelper
from appengine_wrappers import (
- GetAppVersion, DeadlineExceededError, IsDevServer, logservice)
方觉(Fang Jue) 2013/08/14 01:47:42 DeadlineExceededError can still happen even if it'
+ GetAppVersion, IsDevServer, logservice)
from branch_utility import BranchUtility
from compiled_file_system import CompiledFileSystem
from empty_dir_file_system import EmptyDirFileSystem
@@ -54,15 +54,6 @@ class CronServlet(Servlet):
return GetAppVersion()
def Get(self):
- # Crons often time out, and when they do *and* then eventually try to
- # flush logs they die. Turn off autoflush and manually do so at the end.
- logservice.AUTOFLUSH_ENABLED = False
- try:
- return self._GetImpl()
- finally:
- logservice.flush()
-
- def _GetImpl(self):
# Cron strategy:
#
# Find all public template files and static files, and render them. Most of
@@ -88,20 +79,10 @@ class CronServlet(Servlet):
logging.info('cron: rendering %s files from %s...' % (len(files), d))
try:
for i, path in enumerate(files):
- error = None
- try:
- response = get_via_render_servlet(path)
- if response.status != 200:
- error = 'Got %s response' % response.status
- except DeadlineExceededError:
- logging.error(
- 'cron: deadline exceeded rendering %s (%s of %s): %s' % (
- path, i + 1, len(files), traceback.format_exc()))
- raise
- except error:
- pass
- if error:
- logging.error('cron: error rendering %s: %s' % (path, error))
+ response = get_via_render_servlet(path)
+ if response.status != 200:
+ logging.error('cron: error rendering %s: %s' % (
+ path, 'Got %s response' % response.status))
success = False
finally:
logging.info('cron: rendering %s files from %s took %s seconds' % (
@@ -109,52 +90,49 @@ class CronServlet(Servlet):
return success
success = True
- try:
- # Render all of the publicly accessible files.
- cron_runs = [
- # Note: rendering the public templates will pull in all of the private
- # templates.
- (svn_constants.PUBLIC_TEMPLATE_PATH, ''),
- # Note: rendering the public templates will have pulled in the .js
- # and manifest.json files (for listing examples on the API reference
- # pages), but there are still images, CSS, etc.
- (svn_constants.STATIC_PATH, 'static/'),
- ]
- if not IsDevServer():
- cron_runs.append(
- (svn_constants.EXAMPLES_PATH, 'extensions/examples/'))
-
- # Note: don't try to short circuit any of this stuff. We want to run
- # the cron for all the directories regardless of intermediate
- # failures.
- for path, path_prefix in cron_runs:
- success = run_cron_for_dir(path, path_prefix=path_prefix) and success
-
- # TODO(kalman): Generic way for classes to request cron access. The next
- # two special cases are ugly. It would potentially greatly speed up cron
- # runs, too.
-
- # Extension examples have zip files too. Well, so do apps, but the app
- # file system doesn't get the Offline treatment so they don't need cron.
- if not IsDevServer():
- manifest_json = 'manifest.json'
- example_zips = []
- for root, _, files in server_instance.host_file_system.Walk(
- svn_constants.EXAMPLES_PATH):
- example_zips.extend(
- root + '.zip' for name in files if name == manifest_json)
- logging.info('cron: rendering %s example zips...' % len(example_zips))
- start_time = time.time()
- try:
- success = success and all(
- get_via_render_servlet('extensions/examples/%s' % z).status == 200
- for z in example_zips)
- finally:
- logging.info('cron: rendering %s example zips took %s seconds' % (
- len(example_zips), time.time() - start_time))
-
- except DeadlineExceededError:
- success = False
+
+ # Render all of the publicly accessible files.
+ cron_runs = [
+ # Note: rendering the public templates will pull in all of the private
+ # templates.
+ (svn_constants.PUBLIC_TEMPLATE_PATH, ''),
+ # Note: rendering the public templates will have pulled in the .js
+ # and manifest.json files (for listing examples on the API reference
+ # pages), but there are still images, CSS, etc.
+ (svn_constants.STATIC_PATH, 'static/'),
+ ]
+ if not IsDevServer():
+ cron_runs.append(
+ (svn_constants.EXAMPLES_PATH, 'extensions/examples/'))
+
+ # Note: don't try to short circuit any of this stuff. We want to run
+ # the cron for all the directories regardless of intermediate
+ # failures.
+ for path, path_prefix in cron_runs:
+ success = run_cron_for_dir(path, path_prefix=path_prefix) and success
+
+ # TODO(kalman): Generic way for classes to request cron access. The next
+ # two special cases are ugly. It would potentially greatly speed up cron
+ # runs, too.
+
+ # Extension examples have zip files too. Well, so do apps, but the app
+ # file system doesn't get the Offline treatment so they don't need cron.
+ if not IsDevServer():
+ manifest_json = 'manifest.json'
+ example_zips = []
+ for root, _, files in server_instance.host_file_system.Walk(
+ svn_constants.EXAMPLES_PATH):
+ example_zips.extend(
+ root + '.zip' for name in files if name == manifest_json)
+ logging.info('cron: rendering %s example zips...' % len(example_zips))
+ start_time = time.time()
+ try:
+ success = success and all(
+ get_via_render_servlet('extensions/examples/%s' % z).status == 200
+ for z in example_zips)
+ finally:
+ logging.info('cron: rendering %s example zips took %s seconds' % (
+ len(example_zips), time.time() - start_time))
logging.info('cron: running Redirector cron...')
server_instance.redirector.Cron()

Powered by Google App Engine
This is Rietveld 408576698