Make IDLE_TIMEOUT avoidable with account-lock.
Resolves #701. Check the Account-lock 'no_idle_disconnect before kicking an idle session. This also means superusers will never be kicked. Move the idle task to the Server to avoid lock imports in Portal. Make the 'lock' command also able to target Accounts. Also some other fixes.
This commit is contained in:
parent
cdac9678b9
commit
8a2e362b7c
11 changed files with 63 additions and 52 deletions
|
|
@ -73,33 +73,6 @@ AMP_INTERFACE = settings.AMP_INTERFACE
|
|||
AMP_ENABLED = AMP_HOST and AMP_PORT and AMP_INTERFACE
|
||||
|
||||
|
||||
# Maintenance function - this is called repeatedly by the portal.
|
||||
|
||||
_IDLE_TIMEOUT = settings.IDLE_TIMEOUT
|
||||
|
||||
|
||||
def _portal_maintenance():
|
||||
"""
|
||||
The maintenance function handles repeated checks and updates that
|
||||
the server needs to do. It is called every minute.
|
||||
|
||||
"""
|
||||
# check for idle sessions
|
||||
now = time.time()
|
||||
|
||||
reason = "Idle timeout exceeded, disconnecting."
|
||||
for session in [sess for sess in PORTAL_SESSIONS.values()
|
||||
if (now - sess.cmd_last) > _IDLE_TIMEOUT]:
|
||||
session.disconnect(reason=reason)
|
||||
PORTAL_SESSIONS.disconnect(session)
|
||||
|
||||
|
||||
if _IDLE_TIMEOUT > 0:
|
||||
# only start the maintenance task if we care about idling.
|
||||
_maintenance_task = LoopingCall(_portal_maintenance)
|
||||
_maintenance_task.start(60) # called every minute
|
||||
|
||||
|
||||
# -------------------------------------------------------------
|
||||
# Portal Service object
|
||||
# -------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue