summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorBruno Wagner <bwagner@riseup.net>2016-08-31 15:27:20 -0300
committerBruno Wagner <bwagner@riseup.net>2016-08-31 15:27:20 -0300
commita5f1945915c5cac2bc1cf5d7ee8ae888db202ca8 (patch)
treec241dafcb3c86bdb1fd23d685f95f93a804184e8 /service
parenta34e5fe54f074a9a3f570e71cf30d4cda8b9ce41 (diff)
Reading interstitial on class init
The interstitial was being read at every login request, that was a blocking read on the main loop for every user. That file was also being opened and not closed at every request, that would aggravate the 'too many open files' problem
Diffstat (limited to 'service')
-rw-r--r--service/pixelated/resources/login_resource.py4
-rw-r--r--service/pixelated/resources/root_resource.py4
2 files changed, 6 insertions, 2 deletions
diff --git a/service/pixelated/resources/login_resource.py b/service/pixelated/resources/login_resource.py
index ab91176a..1e7c26a5 100644
--- a/service/pixelated/resources/login_resource.py
+++ b/service/pixelated/resources/login_resource.py
@@ -102,6 +102,8 @@ class LoginResource(BaseResource):
self._portal = portal
self._disclaimer_banner = disclaimer_banner
self.putChild('startup-assets', File(self._startup_folder))
+ with open(os.path.join(self._startup_folder, 'Interstitial.html')) as f:
+ self.interstitial = f.read()
def set_portal(self, portal):
self._portal = portal
@@ -129,7 +131,7 @@ class LoginResource(BaseResource):
def render_response(leap_session):
request.setResponseCode(OK)
- request.write(open(os.path.join(self._startup_folder, 'Interstitial.html')).read())
+ request.write(self.interstitial)
request.finish()
self._setup_user_services(leap_session, request)
diff --git a/service/pixelated/resources/root_resource.py b/service/pixelated/resources/root_resource.py
index f27138b0..8353ed7e 100644
--- a/service/pixelated/resources/root_resource.py
+++ b/service/pixelated/resources/root_resource.py
@@ -49,6 +49,8 @@ class RootResource(BaseResource):
self._html_template = open(os.path.join(self._static_folder, 'index.html')).read()
self._services_factory = services_factory
self._child_resources = ChildResourcesMap()
+ with open(os.path.join(self._startup_assets_folder, 'Interstitial.html')) as f:
+ self.interstitial = f.read()
self._startup_mode()
def _startup_mode(self):
@@ -123,7 +125,7 @@ class RootResource(BaseResource):
def render_GET(self, request):
self._add_csrf_cookie(request)
if self._is_starting():
- return open(os.path.join(self._startup_assets_folder, 'Interstitial.html')).read()
+ return self.interstitial
else:
account_email = self.mail_service(request).account_email
response = Template(self._html_template).safe_substitute(account_email=account_email)