Closed LinuxIsCool closed 4 months ago
I noticed this in the python console (panel serve app.py
)
2023-09-08 13:50:51,694 Exception in callback functools.partial(<bound method IOLoop._discard_future_result of <tornado.platform.asyncio.AsyncIOMainLoop object at 0x7efe18c10550>>, <Task finished name='Task-1457' coro=<ServerSession.with_document_locked() done, defined at /home/ygg/.cache/pypoetry/virtualenvs/alloha-qEy3MGg--py3.10/lib/python3.10/site-packages/bokeh/server/sessio
n.py:77> exception=RuntimeError("Models must be owned by only a single document, NumeralTickFormatter(id='p1004', ...) is already in a doc")>)
Traceback (most recent call last):
File "/home/ygg/.cache/pypoetry/virtualenvs/alloha-qEy3MGg--py3.10/lib/python3.10/site-packages/tornado/ioloop.py", line 738, in _run_callback
ret = callback()
File "/home/ygg/.cache/pypoetry/virtualenvs/alloha-qEy3MGg--py3.10/lib/python3.10/site-packages/tornado/ioloop.py", line 762, in _discard_future_result
future.result()
File "/home/ygg/.cache/pypoetry/virtualenvs/alloha-qEy3MGg--py3.10/lib/python3.10/site-packages/bokeh/server/session.py", line 94, in _needs_document_lock_wrapper
result = func(self, *args, **kwargs)
File "/home/ygg/.cache/pypoetry/virtualenvs/alloha-qEy3MGg--py3.10/lib/python3.10/site-packages/bokeh/server/session.py", line 226, in with_document_locked
return func(*args, **kwargs)
File "/home/ygg/.cache/pypoetry/virtualenvs/alloha-qEy3MGg--py3.10/lib/python3.10/site-packages/bokeh/document/callbacks.py", line 485, in wrapper
return invoke_with_curdoc(doc, invoke)
File "/home/ygg/.cache/pypoetry/virtualenvs/alloha-qEy3MGg--py3.10/lib/python3.10/site-packages/bokeh/document/callbacks.py", line 443, in invoke_with_curdoc
return f()
File "/home/ygg/.cache/pypoetry/virtualenvs/alloha-qEy3MGg--py3.10/lib/python3.10/site-packages/bokeh/document/callbacks.py", line 484, in invoke
return f(*args, **kwargs)
File "/home/ygg/.cache/pypoetry/virtualenvs/alloha-qEy3MGg--py3.10/lib/python3.10/site-packages/bokeh/document/callbacks.py", line 182, in remove_then_invoke
return callback()
File "/home/ygg/.cache/pypoetry/virtualenvs/alloha-qEy3MGg--py3.10/lib/python3.10/site-packages/panel/layout/base.py", line 115, in _update_model
with doc.models.freeze():
File "/usr/lib/python3.10/contextlib.py", line 142, in __exit__
next(self.gen)
File "/home/ygg/.cache/pypoetry/virtualenvs/alloha-qEy3MGg--py3.10/lib/python3.10/site-packages/bokeh/document/models.py", line 135, in freeze
self._pop_freeze()
File "/home/ygg/.cache/pypoetry/virtualenvs/alloha-qEy3MGg--py3.10/lib/python3.10/site-packages/bokeh/document/models.py", line 288, in _pop_freeze
self.recompute()
File "/home/ygg/.cache/pypoetry/virtualenvs/alloha-qEy3MGg--py3.10/lib/python3.10/site-packages/bokeh/document/models.py", line 235, in recompute
ma._attach_document(document)
File "/home/ygg/.cache/pypoetry/virtualenvs/alloha-qEy3MGg--py3.10/lib/python3.10/site-packages/bokeh/model/model.py", line 575, in _attach_document
raise RuntimeError(f"Models must be owned by only a single document, {self!r} is already in a doc")
RuntimeError: Models must be owned by only a single document, NumeralTickFormatter(id='p1004', ...) is already in a doc
2023-09-08 13:50:51,704 Exception in callback functools.partial(<bound method IOLoop._discard_future_result of <tornado.platform.asyncio.AsyncIOMainLoop object at 0x7efe18c10550>>, <Task finished name='Task-1458' coro=<ServerSession.with_document_locked() done, defined at /home/ygg/.cache/pypoetry/virtualenvs/alloha-qEy3MGg--py3.10/lib/python3.10/site-packages/bokeh/server/sessio
n.py:77> exception=RuntimeError("Models must be owned by only a single document, NumeralTickFormatter(id='p1004', ...) is already in a doc")>)
Traceback (most recent call last):
File "/home/ygg/.cache/pypoetry/virtualenvs/alloha-qEy3MGg--py3.10/lib/python3.10/site-packages/tornado/ioloop.py", line 738, in _run_callback
ret = callback()
File "/home/ygg/.cache/pypoetry/virtualenvs/alloha-qEy3MGg--py3.10/lib/python3.10/site-packages/tornado/ioloop.py", line 762, in _discard_future_result
future.result()
File "/home/ygg/.cache/pypoetry/virtualenvs/alloha-qEy3MGg--py3.10/lib/python3.10/site-packages/bokeh/server/session.py", line 94, in _needs_document_lock_wrapper
result = func(self, *args, **kwargs)
File "/home/ygg/.cache/pypoetry/virtualenvs/alloha-qEy3MGg--py3.10/lib/python3.10/site-packages/bokeh/server/session.py", line 226, in with_document_locked
return func(*args, **kwargs)
File "/home/ygg/.cache/pypoetry/virtualenvs/alloha-qEy3MGg--py3.10/lib/python3.10/site-packages/bokeh/document/callbacks.py", line 485, in wrapper
return invoke_with_curdoc(doc, invoke)
File "/home/ygg/.cache/pypoetry/virtualenvs/alloha-qEy3MGg--py3.10/lib/python3.10/site-packages/bokeh/document/callbacks.py", line 443, in invoke_with_curdoc
return f()
File "/home/ygg/.cache/pypoetry/virtualenvs/alloha-qEy3MGg--py3.10/lib/python3.10/site-packages/bokeh/document/callbacks.py", line 484, in invoke
return f(*args, **kwargs)
File "/home/ygg/.cache/pypoetry/virtualenvs/alloha-qEy3MGg--py3.10/lib/python3.10/site-packages/bokeh/document/callbacks.py", line 182, in remove_then_invoke
return callback()
File "/home/ygg/.cache/pypoetry/virtualenvs/alloha-qEy3MGg--py3.10/lib/python3.10/site-packages/panel/layout/base.py", line 115, in _update_model
with doc.models.freeze():
File "/usr/lib/python3.10/contextlib.py", line 142, in __exit__
next(self.gen)
File "/home/ygg/.cache/pypoetry/virtualenvs/alloha-qEy3MGg--py3.10/lib/python3.10/site-packages/bokeh/document/models.py", line 135, in freeze
self._pop_freeze()
File "/home/ygg/.cache/pypoetry/virtualenvs/alloha-qEy3MGg--py3.10/lib/python3.10/site-packages/bokeh/document/models.py", line 288, in _pop_freeze
self.recompute()
File "/home/ygg/.cache/pypoetry/virtualenvs/alloha-qEy3MGg--py3.10/lib/python3.10/site-packages/bokeh/document/models.py", line 235, in recompute
ma._attach_document(document)
File "/home/ygg/.cache/pypoetry/virtualenvs/alloha-qEy3MGg--py3.10/lib/python3.10/site-packages/bokeh/model/model.py", line 575, in _attach_document
raise RuntimeError(f"Models must be owned by only a single document, {self!r} is already in a doc")
RuntimeError: Models must be owned by only a single document, NumeralTickFormatter(id='p1004', ...) is already in a doc
2023-09-08 13:50:52,551 Exception in callback functools.partial(<bound method IOLoop._discard_future_result of <tornado.platform.asyncio.AsyncIOMainLoop object at 0x7efe18c10550>>, <Task finished name='Task-1485' coro=<ServerSession.with_document_locked() done, defined at /home/ygg/.cache/pypoetry/virtualenvs/alloha-qEy3MGg--py3.10/lib/python3.10/site-packages/bokeh/server/sessi...
My uneducated guess would be that it's a race condition; before Python finishes processing the data and sending it back to the frontend, the user already clicked a new tab, so this data has no where to go but crash.
I wonder if you can add a disabled=True
to tabs while something is dynamically loading to prevent the user from changing the active tab too quickly?
This is not a Panel issue. If you are using Bokeh models directly you must make sure they are always re-created for each user/session.
ALL software version info
bokeh==3.2.2 holoviews==1.17.1 hvplot==0.8.4 panel==1.2.2 param==1.13.0
Python 3.10.12
Description of expected behavior and the observed behavior
Using panel Tabs, certain tabs will randomly not display anything. If I keep clicking between tabs, then they will eventually all show their content. I'm using
dynamic=True
. My tabs contain hvplot networkx, hvplot bokeh, and tabulators.Complete, minimal, self-contained example code that reproduces the issue
Stack traceback and/or browser JavaScript console output