{"action":"created","comment":{"url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/pulls/comments/37501200","id":37501200,"diff_hunk":"@@ -0,0 +1,128 @@\n+# Copyright 2015 Google Inc. All Rights Reserved.\n+#\n+# Licensed under the Apache License, Version 2.0 (the \"License\");\n+# you may not use this file except in compliance with the License.\n+# You may obtain a copy of the License at\n+#\n+#     http://www.apache.org/licenses/LICENSE-2.0\n+#\n+# Unless required by applicable law or agreed to in writing, software\n+# distributed under the License is distributed on an \"AS IS\" BASIS,\n+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+# See the License for the specific language governing permissions and\n+# limitations under the License.\n+#\n+\"\"\"Configure a user project and instantiate WSGI app meta_app to serve it.\n+\n+Importing this module will result in side-effects, such as registering the\n+project's default ticket via vmstub.Register. This is a broadly compatible way\n+to induce the webserver to run initialization code before starting to serve the\n+WSGI app.\n+\"\"\"\n+\n+import logging\n+import os\n+\n+import cloud_logging\n+from dispatcher import dispatcher\n+from middleware import health_check_middleware\n+from middleware import reset_environment_middleware\n+from wsgi_config import env_vars_from_env_config\n+from wsgi_config import get_module_config\n+from wsgi_config import get_module_config_filename\n+from wsgi_config import load_user_scripts_into_handlers\n+from wsgi_config import ThreadLocalDict\n+from wsgi_config import user_env_vars_from_appinfo\n+\n+from google.appengine.ext.vmruntime import vmconfig\n+from google.appengine.ext.vmruntime import vmstub\n+\n+# Configure logging to output structured JSON to Cloud Logging.\n+root_logger = logging.getLogger('')\n+try:\n+  handler = cloud_logging.CloudLoggingHandler()\n+  root_logger.addHandler(handler)\n+except IOError:\n+  # If the Cloud Logging endpoint does not exist, just use the default handler\n+  # instead. This will be the case when running in local dev mode.\n+  pass\n+\n+root_logger.setLevel(logging.INFO)\n+\n+# Fetch application configuration via the config file.\n+appinfo = get_module_config(get_module_config_filename())\n+env_config = vmconfig.BuildVmAppengineEnvConfig()\n+\n+# Ensure API requests include a valid ticket by default.\n+vmstub.Register(vmstub.VMStub(env_config.default_ticket))\n+\n+# Take an immutable snapshot of env data from env_config. This is added to the\n+# environment in `reset_environment_middleware` in a particular order to ensure\n+# that it cannot be overridden by other steps.\n+frozen_env_config_env = tuple(\n+    env_vars_from_env_config(env_config).iteritems())\n+\n+# Also freeze user env vars specified in app.yaml. Later steps to modify the\n+# environment such as env_vars_from_env_config and request middleware\n+# will overwrite these changes. This is added to the environment in\n+# `reset_environment_middleware`.\n+frozen_user_env = tuple(\n+    user_env_vars_from_appinfo(appinfo).iteritems())\n+\n+# While the primary use of the frozen env vars is for\n+# `reset_environment_middleware`, we'll also add them to the env here to make\n+# them available during app preloading. This is useful for apps which have\n+# side-effects at import time (which is not recommended).\n+os.environ.update(frozen_user_env)\n+os.environ.update(frozen_env_config_env)\n+\n+# Decide whether to enable support for legacy end-to-end tests. This is intended\n+# to be temporary.\n+# TODO(apphosting): Modify the end-to-end test runner to make this step\n+# unnecessary.\n+legacy_e2e_support = appinfo.vm_settings.get('vm_runtime') == 'python'","path":"multicore_runtime/wsgi.py","position":83,"original_position":83,"commit_id":"3b45547acea5bea474a21a892dcdc2e81597491d","original_commit_id":"3b45547acea5bea474a21a892dcdc2e81597491d","user":{"login":"andrewsg","id":686551,"avatar_url":"https://avatars.githubusercontent.com/u/686551?v=3","gravatar_id":"","url":"https://api.github.com/users/andrewsg","html_url":"https://github.com/andrewsg","followers_url":"https://api.github.com/users/andrewsg/followers","following_url":"https://api.github.com/users/andrewsg/following{/other_user}","gists_url":"https://api.github.com/users/andrewsg/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewsg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewsg/subscriptions","organizations_url":"https://api.github.com/users/andrewsg/orgs","repos_url":"https://api.github.com/users/andrewsg/repos","events_url":"https://api.github.com/users/andrewsg/events{/privacy}","received_events_url":"https://api.github.com/users/andrewsg/received_events","type":"User","site_admin":false},"body":"I did not intend that. Nothing tricky is happening here IIRC, so I should just change the name.","created_at":"2015-08-20T07:19:08Z","updated_at":"2015-08-20T07:19:08Z","html_url":"https://github.com/andrewsg/appengine-python-vm-runtime/pull/1#discussion_r37501200","pull_request_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/pulls/comments/37501200"},"html":{"href":"https://github.com/andrewsg/appengine-python-vm-runtime/pull/1#discussion_r37501200"},"pull_request":{"href":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/pulls/1","id":42734664,"html_url":"https://github.com/andrewsg/appengine-python-vm-runtime/pull/1","diff_url":"https://github.com/andrewsg/appengine-python-vm-runtime/pull/1.diff","patch_url":"https://github.com/andrewsg/appengine-python-vm-runtime/pull/1.patch","issue_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/issues/1","number":1,"state":"open","locked":false,"title":"Re-submit files for readability review","user":{"login":"andrewsg","id":686551,"avatar_url":"https://avatars.githubusercontent.com/u/686551?v=3","gravatar_id":"","url":"https://api.github.com/users/andrewsg","html_url":"https://github.com/andrewsg","followers_url":"https://api.github.com/users/andrewsg/followers","following_url":"https://api.github.com/users/andrewsg/following{/other_user}","gists_url":"https://api.github.com/users/andrewsg/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewsg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewsg/subscriptions","organizations_url":"https://api.github.com/users/andrewsg/orgs","repos_url":"https://api.github.com/users/andrewsg/repos","events_url":"https://api.github.com/users/andrewsg/events{/privacy}","received_events_url":"https://api.github.com/users/andrewsg/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-08-18T18:52:55Z","updated_at":"2015-08-20T07:19:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fff401d1efe0807a8f6d9ae1710a718a7f7c4ab5","assignee":{"login":"filbranden","id":106037,"avatar_url":"https://avatars.githubusercontent.com/u/106037?v=3","gravatar_id":"","url":"https://api.github.com/users/filbranden","html_url":"https://github.com/filbranden","followers_url":"https://api.github.com/users/filbranden/followers","following_url":"https://api.github.com/users/filbranden/following{/other_user}","gists_url":"https://api.github.com/users/filbranden/gists{/gist_id}","starred_url":"https://api.github.com/users/filbranden/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/filbranden/subscriptions","organizations_url":"https://api.github.com/users/filbranden/orgs","repos_url":"https://api.github.com/users/filbranden/repos","events_url":"https://api.github.com/users/filbranden/events{/privacy}","received_events_url":"https://api.github.com/users/filbranden/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/pulls/1/commits","review_comments_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/pulls/1/comments","review_comment_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/pulls/comments{/number}","comments_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/issues/1/comments","statuses_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/statuses/3b45547acea5bea474a21a892dcdc2e81597491d","head":{"label":"andrewsg:readability","ref":"readability","sha":"3b45547acea5bea474a21a892dcdc2e81597491d","user":{"login":"andrewsg","id":686551,"avatar_url":"https://avatars.githubusercontent.com/u/686551?v=3","gravatar_id":"","url":"https://api.github.com/users/andrewsg","html_url":"https://github.com/andrewsg","followers_url":"https://api.github.com/users/andrewsg/followers","following_url":"https://api.github.com/users/andrewsg/following{/other_user}","gists_url":"https://api.github.com/users/andrewsg/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewsg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewsg/subscriptions","organizations_url":"https://api.github.com/users/andrewsg/orgs","repos_url":"https://api.github.com/users/andrewsg/repos","events_url":"https://api.github.com/users/andrewsg/events{/privacy}","received_events_url":"https://api.github.com/users/andrewsg/received_events","type":"User","site_admin":false},"repo":{"id":37627647,"name":"appengine-python-vm-runtime","full_name":"andrewsg/appengine-python-vm-runtime","owner":{"login":"andrewsg","id":686551,"avatar_url":"https://avatars.githubusercontent.com/u/686551?v=3","gravatar_id":"","url":"https://api.github.com/users/andrewsg","html_url":"https://github.com/andrewsg","followers_url":"https://api.github.com/users/andrewsg/followers","following_url":"https://api.github.com/users/andrewsg/following{/other_user}","gists_url":"https://api.github.com/users/andrewsg/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewsg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewsg/subscriptions","organizations_url":"https://api.github.com/users/andrewsg/orgs","repos_url":"https://api.github.com/users/andrewsg/repos","events_url":"https://api.github.com/users/andrewsg/events{/privacy}","received_events_url":"https://api.github.com/users/andrewsg/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/andrewsg/appengine-python-vm-runtime","description":"Google Managed VMs Python Runtime","fork":true,"url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime","forks_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/forks","keys_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/teams","hooks_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/hooks","issue_events_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/issues/events{/number}","events_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/events","assignees_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/assignees{/user}","branches_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/branches{/branch}","tags_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/tags","blobs_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/git/refs{/sha}","trees_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/statuses/{sha}","languages_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/languages","stargazers_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/stargazers","contributors_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/contributors","subscribers_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/subscribers","subscription_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/subscription","commits_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/commits{/sha}","git_commits_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/git/commits{/sha}","comments_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/comments{/number}","issue_comment_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/issues/comments{/number}","contents_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/contents/{+path}","compare_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/merges","archive_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/downloads","issues_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/issues{/number}","pulls_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/pulls{/number}","milestones_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/milestones{/number}","notifications_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/labels{/name}","releases_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/releases{/id}","created_at":"2015-06-18T00:02:48Z","updated_at":"2015-06-18T00:03:17Z","pushed_at":"2015-08-18T18:52:55Z","git_url":"git://github.com/andrewsg/appengine-python-vm-runtime.git","ssh_url":"git@github.com:andrewsg/appengine-python-vm-runtime.git","clone_url":"https://github.com/andrewsg/appengine-python-vm-runtime.git","svn_url":"https://github.com/andrewsg/appengine-python-vm-runtime","homepage":"","size":26009,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"andrewsg:readability-base","ref":"readability-base","sha":"93234db0efb2f3465ade3198575adffb0bc1afef","user":{"login":"andrewsg","id":686551,"avatar_url":"https://avatars.githubusercontent.com/u/686551?v=3","gravatar_id":"","url":"https://api.github.com/users/andrewsg","html_url":"https://github.com/andrewsg","followers_url":"https://api.github.com/users/andrewsg/followers","following_url":"https://api.github.com/users/andrewsg/following{/other_user}","gists_url":"https://api.github.com/users/andrewsg/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewsg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewsg/subscriptions","organizations_url":"https://api.github.com/users/andrewsg/orgs","repos_url":"https://api.github.com/users/andrewsg/repos","events_url":"https://api.github.com/users/andrewsg/events{/privacy}","received_events_url":"https://api.github.com/users/andrewsg/received_events","type":"User","site_admin":false},"repo":{"id":37627647,"name":"appengine-python-vm-runtime","full_name":"andrewsg/appengine-python-vm-runtime","owner":{"login":"andrewsg","id":686551,"avatar_url":"https://avatars.githubusercontent.com/u/686551?v=3","gravatar_id":"","url":"https://api.github.com/users/andrewsg","html_url":"https://github.com/andrewsg","followers_url":"https://api.github.com/users/andrewsg/followers","following_url":"https://api.github.com/users/andrewsg/following{/other_user}","gists_url":"https://api.github.com/users/andrewsg/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewsg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewsg/subscriptions","organizations_url":"https://api.github.com/users/andrewsg/orgs","repos_url":"https://api.github.com/users/andrewsg/repos","events_url":"https://api.github.com/users/andrewsg/events{/privacy}","received_events_url":"https://api.github.com/users/andrewsg/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/andrewsg/appengine-python-vm-runtime","description":"Google Managed VMs Python Runtime","fork":true,"url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime","forks_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/forks","keys_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/teams","hooks_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/hooks","issue_events_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/issues/events{/number}","events_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/events","assignees_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/assignees{/user}","branches_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/branches{/branch}","tags_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/tags","blobs_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/git/refs{/sha}","trees_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/statuses/{sha}","languages_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/languages","stargazers_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/stargazers","contributors_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/contributors","subscribers_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/subscribers","subscription_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/subscription","commits_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/commits{/sha}","git_commits_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/git/commits{/sha}","comments_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/comments{/number}","issue_comment_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/issues/comments{/number}","contents_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/contents/{+path}","compare_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/merges","archive_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/downloads","issues_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/issues{/number}","pulls_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/pulls{/number}","milestones_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/milestones{/number}","notifications_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/labels{/name}","releases_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/releases{/id}","created_at":"2015-06-18T00:02:48Z","updated_at":"2015-06-18T00:03:17Z","pushed_at":"2015-08-18T18:52:55Z","git_url":"git://github.com/andrewsg/appengine-python-vm-runtime.git","ssh_url":"git@github.com:andrewsg/appengine-python-vm-runtime.git","clone_url":"https://github.com/andrewsg/appengine-python-vm-runtime.git","svn_url":"https://github.com/andrewsg/appengine-python-vm-runtime","homepage":"","size":26009,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/pulls/1"},"html":{"href":"https://github.com/andrewsg/appengine-python-vm-runtime/pull/1"},"issue":{"href":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/issues/1"},"comments":{"href":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/statuses/3b45547acea5bea474a21a892dcdc2e81597491d"}}}}