From e118de84d60e6f0d7662dcbb6aa362f452dda6ba Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Wed, 29 Dec 2021 20:56:03 +0100 Subject: webapp: improve performance html_response expects a str-generator, but when we call the render method, we receive a plain str. It can be iterated - one character at a time. That's what encode_and_buffer will do in this case. So better stream all the time. --- webapp.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/webapp.py b/webapp.py index 8f5d342..9993cb0 100755 --- a/webapp.py +++ b/webapp.py @@ -100,7 +100,7 @@ class Application: elif endpoint == "index": if not request.environ["PATH_INFO"]: raise InternalRedirect("/") - return html_response(index_template.render(dict(urlroot=""))) + return html_response(index_template.stream(dict(urlroot=""))) elif endpoint == "source": return self.show_source(args["package"]) raise NotFound() @@ -159,7 +159,7 @@ class Application: (params["pid"],)) params["issues"] = dict(cur.fetchall()) cur.close() - return html_response(package_template.render(params)) + return html_response(package_template.stream(params)) def compute_comparison(self, pid1, pid2): """Compute a sequence of comparison objects ordered by the size of the @@ -237,7 +237,7 @@ class Application: raise NotFound() params = dict(function=function, hashvalue=hashvalue, entries=entries, urlroot="../..") - return html_response(hash_template.render(params)) + return html_response(hash_template.stream(params)) def show_source(self, package): with contextlib.closing(self.db.cursor()) as cur: @@ -256,7 +256,7 @@ class Application: if not (oldentry and oldentry["savable"] >= size): binpkgs[binary] = entry params = dict(source=package, packages=binpkgs, urlroot="..") - return html_response(source_template.render(params)) + return html_response(source_template.stream(params)) def main(): parser = argparse.ArgumentParser() -- cgit v1.2.3