[web] fix AbstractSessionManager.clean_sessions (closes #5757240)

sessions were not closed if "last_usage_time = session.cnx.check()" actually raises an AtributeError.

authorDavid Douard <david.douard@logilab.fr>
changeset9826dc78eec1
branchdefault
phasepublic
hiddenno
parent revision#8fbff2247816 [migration/3.21] ask fewer questions
child revision#1776c956e1ba [web/request] replace the nexttabfunc session data by a simple integer, #5583bebe9e7f [pkg] 3.21.1
files modified by this revision
web/views/sessions.py
# HG changeset patch
# User David Douard <david.douard@logilab.fr>
# Date 1438075296 -7200
# Tue Jul 28 11:21:36 2015 +0200
# Node ID 9826dc78eec19ffe5e66aff7d375b7f7aadd7569
# Parent 8fbff2247816e382d14d6a80e05cc60d1a4b3f7e
[web] fix AbstractSessionManager.clean_sessions (closes #5757240)

sessions were not closed if "last_usage_time = session.cnx.check()" actually
raises an AtributeError.

diff --git a/web/views/sessions.py b/web/views/sessions.py
@@ -58,19 +58,20 @@
1              except AttributeError:
2                  last_usage_time = session.mtime
3              except BadConnectionId:
4                  self.close_session(session)
5                  closed += 1
6 -            else:
7 -                no_use_time = (time() - last_usage_time)
8 -                if session.anonymous_session:
9 -                    if no_use_time >= self.cleanup_anon_session_time:
10 -                        self.close_session(session)
11 -                        closed += 1
12 -                elif session_time is not None and no_use_time >= session_time:
13 +                continue
14 +
15 +            no_use_time = (time() - last_usage_time)
16 +            if session.anonymous_session:
17 +                if no_use_time >= self.cleanup_anon_session_time:
18                      self.close_session(session)
19                      closed += 1
20 +            elif session_time is not None and no_use_time >= session_time:
21 +                self.close_session(session)
22 +                closed += 1
23          return closed, total - closed
24 
25      def current_sessions(self):
26          """return currently open sessions"""
27          raise NotImplementedError()