Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle session_info correctly in Templates #1617

Merged
merged 1 commit into from
Oct 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions panel/io/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,16 @@ def _server_url(url, port):


def init_doc(doc):
from ..config import config

doc = doc or curdoc()
if not doc.session_context or config.session_history == 0:
if not doc.session_context:
return doc

from ..config import config
session_id = doc.session_context.id
sessions = state.session_info['sessions']
if config.session_history == 0 or session_id in sessions:
return doc

state.session_info['total'] += 1
if config.session_history > 0 and len(sessions) >= config.session_history:
old_history = list(sessions.items())
Expand Down
5 changes: 3 additions & 2 deletions panel/viewable.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,9 @@ def _server_destroy(self, session_context):
Server lifecycle hook triggered when session is destroyed.
"""
session_id = session_context.session.id
if session_id in state.session_info:
session_info = state.session_info['sessions'][session_id]
sessions = state.session_info['sessions']
if session_id in sessions and sessions['ended'] is None:
session_info = sessions[session_id]
state.session_info['live'] -= 1
session_info.update({
'ended': dt.datetime.now().timestamp()
Expand Down