Empty session_info when rendering with lazy=True
Bug Report
ALL software version info
Python 3.8.10 (tags/v3.8.10:3d8993a, May 3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)] Panel: 0.13.1 Bokeh: 2.4.3 Param: 1.12.2
Description of expected behavior and the observed behavior
When serving a template with the lazy flag:
pn.panel(main_pane, lazy=True)
The app does not track the session object if started with:
panel serve
But when the admin app is enabled with
panel server --admin
The session_info object is tracked as should be the case. Filing it as a bug, but this could be a design decision, unclear.
Complete, minimal, self-contained example code that reproduces the issue
import panel as pn
input_1 = pn.widgets.Select(options=[1, 2, 3, 4], name='Input 1')
input_2 = pn.widgets.Select(options=[1, 2, 3, 4], name='Input 2')
num_of_calls = 0
def sidebar():
return pn.Row(pn.Column(pn.Row(input_1), pn.Row(input_2)))
@pn.depends(input_1, input_2)
def main_pane(input1_val, input2_val):
global num_of_calls
num_of_calls += 1
print(pn.state.session_info)
md = pn.pane.Markdown(f'{input1_val + input2_val} - {num_of_calls}')
return pn.Row(pn.Column(md))
if __name__.startswith('bokeh'):
pn.extension()
t = pn.template.FastGridTemplate(
site='Panel', title='Test',
sidebar=sidebar()
)
t.main[:1, :2] = pn.panel(main_pane, lazy=True)
t.servable()
panel server app.py --port 8100
Stack traceback and/or browser JavaScript console output
2022-09-08 18:12:49,924 Bokeh app running at: http://localhost:8100/app 2022-09-08 18:12:49,925 Starting Bokeh server with process id: 11796 {'total': 0, 'live': 0, 'sessions': OrderedDict()} 2022-09-08 18:12:52,338 WebSocket connection opened 2022-09-08 18:12:52,340 ServerConnection created {'total': 0, 'live': 0, 'sessions': OrderedDict()}
With --admin enabled in CLI
panel server app.py --port 8100 --admin
2022-09-08 18:42:52,297 Bokeh app running at: http://localhost:8100/app 2022-09-08 18:42:52,298 Starting Bokeh server with process id: 10332 {'total': 1, 'live': 0, 'sessions': OrderedDict([('07iSav2D2SWW4JkUNvmeOvCQXCaJjINxuCV8D0z9Rqgn', {'launched': 1662642774.96689, 'started': 1662642775.071888, 'rendered': None, 'ended': None, 'user_agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36'})])}
Screenshots or screencasts of the bug in action
This is not unexpected, session_info is only tracked when either --admin or --session-history is set. I'd very happily accept suggestions and particularly PRs to clarify this in the documentation.
Thank you for clarifying. I posted it so it can be flagged and fixed if the behavior is unexpected.