We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
/about/stats.json is broken
[stats.json](https://www.gittip.com/about/stats.json) is broken, I guess because of commit https://github.com/gittip/www.gittip.com/commit/892b1c28d127a18858032c88bd3d065cae973c34 by @clone1018.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `configure-aspen.py`
Content:
```
1 from __future__ import division
2 
3 from importlib import import_module
4 import os
5 import sys
6 import threading
7 import time
8 import traceback
9 
10 import gittip
11 import gittip.wireup
12 from gittip import canonize, configure_payments
13 from gittip.security import authentication, csrf, x_frame_options
14 from gittip.utils import cache_static, timer
15 from gittip.elsewhere import platform_classes
16 
17 
18 from aspen import log_dammit
19 
20 # Wireup Algorithm
21 # ================
22 
23 version_file = os.path.join(website.www_root, 'version.txt')
24 __version__ = open(version_file).read().strip()
25 website.version = os.environ['__VERSION__'] = __version__
26 
27 
28 website.renderer_default = "jinja2"
29 website.default_renderers_by_media_type['application/json'] = 'stdlib_format'
30 
31 website.renderer_factories['jinja2'].Renderer.global_context = {
32     'range': range,
33     'unicode': unicode,
34     'enumerate': enumerate,
35     'len': len,
36     'float': float,
37     'type': type,
38     'str': str
39 }
40 
41 
42 gittip.wireup.canonical()
43 website.db = gittip.wireup.db()
44 gittip.wireup.billing()
45 gittip.wireup.username_restrictions(website)
46 gittip.wireup.nanswers()
47 gittip.wireup.envvars(website)
48 tell_sentry = gittip.wireup.make_sentry_teller(website)
49 
50 # this serves two purposes:
51 #  1) ensure all platform classes are created (and thus added to platform_classes)
52 #  2) keep the platform modules around to be added to the context below
53 platform_modules = {platform: import_module("gittip.elsewhere.%s" % platform)
54                     for platform in platform_classes}
55 
56 # The homepage wants expensive queries. Let's periodically select into an
57 # intermediate table.
58 
59 UPDATE_HOMEPAGE_EVERY = int(os.environ['UPDATE_HOMEPAGE_EVERY'])
60 def update_homepage_queries():
61     from gittip import utils
62     while 1:
63         try:
64             utils.update_global_stats(website)
65             utils.update_homepage_queries_once(website.db)
66             website.db.self_check()
67         except:
68             exception = sys.exc_info()[0]
69             tell_sentry(exception)
70             tb = traceback.format_exc().strip()
71             log_dammit(tb)
72         time.sleep(UPDATE_HOMEPAGE_EVERY)
73 
74 if UPDATE_HOMEPAGE_EVERY > 0:
75     homepage_updater = threading.Thread(target=update_homepage_queries)
76     homepage_updater.daemon = True
77     homepage_updater.start()
78 else:
79     from gittip import utils
80     utils.update_global_stats(website)
81 
82 
83 # Server Algorithm
84 # ================
85 
86 def up_minthreads(website):
87     # https://github.com/gittip/www.gittip.com/issues/1098
88     # Discovered the following API by inspecting in pdb and browsing source.
89     # This requires network_engine.bind to have already been called.
90     request_queue = website.network_engine.cheroot_server.requests
91     request_queue.min = website.min_threads
92 
93 
94 def setup_busy_threads_logging(website):
95     # https://github.com/gittip/www.gittip.com/issues/1572
96     log_every = website.log_busy_threads_every
97     if log_every == 0:
98         return
99 
100     pool = website.network_engine.cheroot_server.requests
101     def log_busy_threads():
102         time.sleep(0.5)  # without this we get a single log message where all threads are busy
103         while 1:
104 
105             # Use pool.min and not pool.max because of the semantics of these
106             # inside of Cheroot. (Max is a hard limit used only when pool.grow
107             # is called, and it's never called except when the pool starts up,
108             # when it's called with pool.min.)
109 
110             nbusy_threads = pool.min - pool.idle
111             print("sample#aspen.busy_threads={}".format(nbusy_threads))
112             time.sleep(log_every)
113 
114     thread = threading.Thread(target=log_busy_threads)
115     thread.daemon = True
116     thread.start()
117 
118 
119 website.server_algorithm.insert_before('start', up_minthreads)
120 website.server_algorithm.insert_before('start', setup_busy_threads_logging)
121 
122 
123 # Website Algorithm
124 # =================
125 
126 def add_stuff_to_context(request):
127     request.context['username'] = None
128     request.context.update(platform_modules)
129 
130 def scab_body_onto_response(response):
131 
132     # This is a workaround for a Cheroot bug, where the connection is closed
133     # too early if there is no body:
134     #
135     # https://bitbucket.org/cherrypy/cheroot/issue/1/fail-if-passed-zero-bytes
136     #
137     # This Cheroot bug is manifesting because of a change in Aspen's behavior
138     # with the algorithm.py refactor in 0.27+: Aspen no longer sets a body for
139     # 302s as it used to. This means that all redirects are breaking
140     # intermittently (sometimes the client seems not to care that the
141     # connection is closed too early, so I guess there's some timing
142     # involved?), which is affecting a number of parts of Gittip, notably
143     # around logging in (#1859).
144 
145     if not response.body:
146         response.body = '*sigh*'
147 
148 
149 algorithm = website.algorithm
150 algorithm.functions = [ timer.start
151                       , algorithm['parse_environ_into_request']
152                       , algorithm['tack_website_onto_request']
153                       , algorithm['raise_200_for_OPTIONS']
154 
155                       , canonize
156                       , configure_payments
157                       , authentication.inbound
158                       , csrf.inbound
159                       , add_stuff_to_context
160 
161                       , algorithm['dispatch_request_to_filesystem']
162                       , algorithm['apply_typecasters_to_path']
163 
164                       , cache_static.inbound
165 
166                       , algorithm['get_response_for_socket']
167                       , algorithm['get_resource_for_request']
168                       , algorithm['get_response_for_resource']
169 
170                       , tell_sentry
171                       , algorithm['get_response_for_exception']
172 
173                       , gittip.outbound
174                       , authentication.outbound
175                       , csrf.outbound
176                       , cache_static.outbound
177                       , x_frame_options
178 
179                       , algorithm['log_traceback_for_5xx']
180                       , algorithm['delegate_error_to_simplate']
181                       , tell_sentry
182                       , algorithm['log_traceback_for_exception']
183                       , algorithm['log_result_of_request']
184 
185                       , scab_body_onto_response
186                       , timer.end
187                       , tell_sentry
188                        ]
189
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/configure-aspen.py b/configure-aspen.py
--- a/configure-aspen.py
+++ b/configure-aspen.py
@@ -26,7 +26,6 @@
 
 
 website.renderer_default = "jinja2"
-website.default_renderers_by_media_type['application/json'] = 'stdlib_format'
 
 website.renderer_factories['jinja2'].Renderer.global_context = {
     'range': range,

{"golden_diff": "diff --git a/configure-aspen.py b/configure-aspen.py\n--- a/configure-aspen.py\n+++ b/configure-aspen.py\n@@ -26,7 +26,6 @@\n \n \n website.renderer_default = \"jinja2\"\n-website.default_renderers_by_media_type['application/json'] = 'stdlib_format'\n \n website.renderer_factories['jinja2'].Renderer.global_context = {\n     'range': range,\n", "issue": "/about/stats.json is broken\n[stats.json](https://www.gittip.com/about/stats.json) is broken, I guess because of commit https://github.com/gittip/www.gittip.com/commit/892b1c28d127a18858032c88bd3d065cae973c34 by @clone1018.\n\n", "before_files": [{"content": "from __future__ import division\n\nfrom importlib import import_module\nimport os\nimport sys\nimport threading\nimport time\nimport traceback\n\nimport gittip\nimport gittip.wireup\nfrom gittip import canonize, configure_payments\nfrom gittip.security import authentication, csrf, x_frame_options\nfrom gittip.utils import cache_static, timer\nfrom gittip.elsewhere import platform_classes\n\n\nfrom aspen import log_dammit\n\n# Wireup Algorithm\n# ================\n\nversion_file = os.path.join(website.www_root, 'version.txt')\n__version__ = open(version_file).read().strip()\nwebsite.version = os.environ['__VERSION__'] = __version__\n\n\nwebsite.renderer_default = \"jinja2\"\nwebsite.default_renderers_by_media_type['application/json'] = 'stdlib_format'\n\nwebsite.renderer_factories['jinja2'].Renderer.global_context = {\n    'range': range,\n    'unicode': unicode,\n    'enumerate': enumerate,\n    'len': len,\n    'float': float,\n    'type': type,\n    'str': str\n}\n\n\ngittip.wireup.canonical()\nwebsite.db = gittip.wireup.db()\ngittip.wireup.billing()\ngittip.wireup.username_restrictions(website)\ngittip.wireup.nanswers()\ngittip.wireup.envvars(website)\ntell_sentry = gittip.wireup.make_sentry_teller(website)\n\n# this serves two purposes:\n#  1) ensure all platform classes are created (and thus added to platform_classes)\n#  2) keep the platform modules around to be added to the context below\nplatform_modules = {platform: import_module(\"gittip.elsewhere.%s\" % platform)\n                    for platform in platform_classes}\n\n# The homepage wants expensive queries. Let's periodically select into an\n# intermediate table.\n\nUPDATE_HOMEPAGE_EVERY = int(os.environ['UPDATE_HOMEPAGE_EVERY'])\ndef update_homepage_queries():\n    from gittip import utils\n    while 1:\n        try:\n            utils.update_global_stats(website)\n            utils.update_homepage_queries_once(website.db)\n            website.db.self_check()\n        except:\n            exception = sys.exc_info()[0]\n            tell_sentry(exception)\n            tb = traceback.format_exc().strip()\n            log_dammit(tb)\n        time.sleep(UPDATE_HOMEPAGE_EVERY)\n\nif UPDATE_HOMEPAGE_EVERY > 0:\n    homepage_updater = threading.Thread(target=update_homepage_queries)\n    homepage_updater.daemon = True\n    homepage_updater.start()\nelse:\n    from gittip import utils\n    utils.update_global_stats(website)\n\n\n# Server Algorithm\n# ================\n\ndef up_minthreads(website):\n    # https://github.com/gittip/www.gittip.com/issues/1098\n    # Discovered the following API by inspecting in pdb and browsing source.\n    # This requires network_engine.bind to have already been called.\n    request_queue = website.network_engine.cheroot_server.requests\n    request_queue.min = website.min_threads\n\n\ndef setup_busy_threads_logging(website):\n    # https://github.com/gittip/www.gittip.com/issues/1572\n    log_every = website.log_busy_threads_every\n    if log_every == 0:\n        return\n\n    pool = website.network_engine.cheroot_server.requests\n    def log_busy_threads():\n        time.sleep(0.5)  # without this we get a single log message where all threads are busy\n        while 1:\n\n            # Use pool.min and not pool.max because of the semantics of these\n            # inside of Cheroot. (Max is a hard limit used only when pool.grow\n            # is called, and it's never called except when the pool starts up,\n            # when it's called with pool.min.)\n\n            nbusy_threads = pool.min - pool.idle\n            print(\"sample#aspen.busy_threads={}\".format(nbusy_threads))\n            time.sleep(log_every)\n\n    thread = threading.Thread(target=log_busy_threads)\n    thread.daemon = True\n    thread.start()\n\n\nwebsite.server_algorithm.insert_before('start', up_minthreads)\nwebsite.server_algorithm.insert_before('start', setup_busy_threads_logging)\n\n\n# Website Algorithm\n# =================\n\ndef add_stuff_to_context(request):\n    request.context['username'] = None\n    request.context.update(platform_modules)\n\ndef scab_body_onto_response(response):\n\n    # This is a workaround for a Cheroot bug, where the connection is closed\n    # too early if there is no body:\n    #\n    # https://bitbucket.org/cherrypy/cheroot/issue/1/fail-if-passed-zero-bytes\n    #\n    # This Cheroot bug is manifesting because of a change in Aspen's behavior\n    # with the algorithm.py refactor in 0.27+: Aspen no longer sets a body for\n    # 302s as it used to. This means that all redirects are breaking\n    # intermittently (sometimes the client seems not to care that the\n    # connection is closed too early, so I guess there's some timing\n    # involved?), which is affecting a number of parts of Gittip, notably\n    # around logging in (#1859).\n\n    if not response.body:\n        response.body = '*sigh*'\n\n\nalgorithm = website.algorithm\nalgorithm.functions = [ timer.start\n                      , algorithm['parse_environ_into_request']\n                      , algorithm['tack_website_onto_request']\n                      , algorithm['raise_200_for_OPTIONS']\n\n                      , canonize\n                      , configure_payments\n                      , authentication.inbound\n                      , csrf.inbound\n                      , add_stuff_to_context\n\n                      , algorithm['dispatch_request_to_filesystem']\n                      , algorithm['apply_typecasters_to_path']\n\n                      , cache_static.inbound\n\n                      , algorithm['get_response_for_socket']\n                      , algorithm['get_resource_for_request']\n                      , algorithm['get_response_for_resource']\n\n                      , tell_sentry\n                      , algorithm['get_response_for_exception']\n\n                      , gittip.outbound\n                      , authentication.outbound\n                      , csrf.outbound\n                      , cache_static.outbound\n                      , x_frame_options\n\n                      , algorithm['log_traceback_for_5xx']\n                      , algorithm['delegate_error_to_simplate']\n                      , tell_sentry\n                      , algorithm['log_traceback_for_exception']\n                      , algorithm['log_result_of_request']\n\n                      , scab_body_onto_response\n                      , timer.end\n                      , tell_sentry\n                       ]\n", "path": "configure-aspen.py"}], "after_files": [{"content": "from __future__ import division\n\nfrom importlib import import_module\nimport os\nimport sys\nimport threading\nimport time\nimport traceback\n\nimport gittip\nimport gittip.wireup\nfrom gittip import canonize, configure_payments\nfrom gittip.security import authentication, csrf, x_frame_options\nfrom gittip.utils import cache_static, timer\nfrom gittip.elsewhere import platform_classes\n\n\nfrom aspen import log_dammit\n\n# Wireup Algorithm\n# ================\n\nversion_file = os.path.join(website.www_root, 'version.txt')\n__version__ = open(version_file).read().strip()\nwebsite.version = os.environ['__VERSION__'] = __version__\n\n\nwebsite.renderer_default = \"jinja2\"\n\nwebsite.renderer_factories['jinja2'].Renderer.global_context = {\n    'range': range,\n    'unicode': unicode,\n    'enumerate': enumerate,\n    'len': len,\n    'float': float,\n    'type': type,\n    'str': str\n}\n\n\ngittip.wireup.canonical()\nwebsite.db = gittip.wireup.db()\ngittip.wireup.billing()\ngittip.wireup.username_restrictions(website)\ngittip.wireup.nanswers()\ngittip.wireup.envvars(website)\ntell_sentry = gittip.wireup.make_sentry_teller(website)\n\n# this serves two purposes:\n#  1) ensure all platform classes are created (and thus added to platform_classes)\n#  2) keep the platform modules around to be added to the context below\nplatform_modules = {platform: import_module(\"gittip.elsewhere.%s\" % platform)\n                    for platform in platform_classes}\n\n# The homepage wants expensive queries. Let's periodically select into an\n# intermediate table.\n\nUPDATE_HOMEPAGE_EVERY = int(os.environ['UPDATE_HOMEPAGE_EVERY'])\ndef update_homepage_queries():\n    from gittip import utils\n    while 1:\n        try:\n            utils.update_global_stats(website)\n            utils.update_homepage_queries_once(website.db)\n            website.db.self_check()\n        except:\n            exception = sys.exc_info()[0]\n            tell_sentry(exception)\n            tb = traceback.format_exc().strip()\n            log_dammit(tb)\n        time.sleep(UPDATE_HOMEPAGE_EVERY)\n\nif UPDATE_HOMEPAGE_EVERY > 0:\n    homepage_updater = threading.Thread(target=update_homepage_queries)\n    homepage_updater.daemon = True\n    homepage_updater.start()\nelse:\n    from gittip import utils\n    utils.update_global_stats(website)\n\n\n# Server Algorithm\n# ================\n\ndef up_minthreads(website):\n    # https://github.com/gittip/www.gittip.com/issues/1098\n    # Discovered the following API by inspecting in pdb and browsing source.\n    # This requires network_engine.bind to have already been called.\n    request_queue = website.network_engine.cheroot_server.requests\n    request_queue.min = website.min_threads\n\n\ndef setup_busy_threads_logging(website):\n    # https://github.com/gittip/www.gittip.com/issues/1572\n    log_every = website.log_busy_threads_every\n    if log_every == 0:\n        return\n\n    pool = website.network_engine.cheroot_server.requests\n    def log_busy_threads():\n        time.sleep(0.5)  # without this we get a single log message where all threads are busy\n        while 1:\n\n            # Use pool.min and not pool.max because of the semantics of these\n            # inside of Cheroot. (Max is a hard limit used only when pool.grow\n            # is called, and it's never called except when the pool starts up,\n            # when it's called with pool.min.)\n\n            nbusy_threads = pool.min - pool.idle\n            print(\"sample#aspen.busy_threads={}\".format(nbusy_threads))\n            time.sleep(log_every)\n\n    thread = threading.Thread(target=log_busy_threads)\n    thread.daemon = True\n    thread.start()\n\n\nwebsite.server_algorithm.insert_before('start', up_minthreads)\nwebsite.server_algorithm.insert_before('start', setup_busy_threads_logging)\n\n\n# Website Algorithm\n# =================\n\ndef add_stuff_to_context(request):\n    request.context['username'] = None\n    request.context.update(platform_modules)\n\ndef scab_body_onto_response(response):\n\n    # This is a workaround for a Cheroot bug, where the connection is closed\n    # too early if there is no body:\n    #\n    # https://bitbucket.org/cherrypy/cheroot/issue/1/fail-if-passed-zero-bytes\n    #\n    # This Cheroot bug is manifesting because of a change in Aspen's behavior\n    # with the algorithm.py refactor in 0.27+: Aspen no longer sets a body for\n    # 302s as it used to. This means that all redirects are breaking\n    # intermittently (sometimes the client seems not to care that the\n    # connection is closed too early, so I guess there's some timing\n    # involved?), which is affecting a number of parts of Gittip, notably\n    # around logging in (#1859).\n\n    if not response.body:\n        response.body = '*sigh*'\n\n\nalgorithm = website.algorithm\nalgorithm.functions = [ timer.start\n                      , algorithm['parse_environ_into_request']\n                      , algorithm['tack_website_onto_request']\n                      , algorithm['raise_200_for_OPTIONS']\n\n                      , canonize\n                      , configure_payments\n                      , authentication.inbound\n                      , csrf.inbound\n                      , add_stuff_to_context\n\n                      , algorithm['dispatch_request_to_filesystem']\n                      , algorithm['apply_typecasters_to_path']\n\n                      , cache_static.inbound\n\n                      , algorithm['get_response_for_socket']\n                      , algorithm['get_resource_for_request']\n                      , algorithm['get_response_for_resource']\n\n                      , tell_sentry\n                      , algorithm['get_response_for_exception']\n\n                      , gittip.outbound\n                      , authentication.outbound\n                      , csrf.outbound\n                      , cache_static.outbound\n                      , x_frame_options\n\n                      , algorithm['log_traceback_for_5xx']\n                      , algorithm['delegate_error_to_simplate']\n                      , tell_sentry\n                      , algorithm['log_traceback_for_exception']\n                      , algorithm['log_result_of_request']\n\n                      , scab_body_onto_response\n                      , timer.end\n                      , tell_sentry\n                       ]\n", "path": "configure-aspen.py"}]}