Mercurial > libervia-web
diff libervia/server/pages.py @ 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 | 92d0a2b785fd |
children | b2d067339de3 |
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):