changeset 1208:584e29d9510a

pages: display a warning instead or raising exception if write fails: request.write sometimes raise an AttributeError. This case happens most of time when browser tab is closed or reloaded before the page has been written. fix 214
author Goffi <goffi@goffi.org>
date Fri, 19 Jul 2019 18:01:38 +0200
parents 67ec22356457
children 13447f785ba1
files libervia/server/pages.py
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libervia/server/pages.py	Fri Jul 19 18:01:25 2019 +0200
+++ b/libervia/server/pages.py	Fri Jul 19 18:01:38 2019 +0200
@@ -1197,7 +1197,12 @@
             self._do_cache = None
             self._checkCacheHeaders(request, page_cache)
 
-        request.write(data_encoded)
+        try:
+            request.write(data_encoded)
+        except AttributeError:
+            log.warning(_(u"Can't write page, the request has probably been cancelled "
+                          u"(browser tab closed or reloaded)"))
+            return
         request.finish()
 
     def _subpagesHandler(self, __, request):