RuntimeError: Patched curdoc has been previously destroyed

Running panel from a batch file. Sometimes this error comes up and the client sees blank panel when loading the page. Any ideas how to avoid this, or close the batch file and restart programmatically?

2022-06-02 14:11:01,744 Exception in callback functools.partial(<bound method IOLoop._discard_future_result of <tornado.platform.asyncio.AsyncIOMainLoop object at 0x0000019C379F1AC8>>, <Task finished coro=<WSHandler._async_open() done, defined at C:\Users\mladmin\AppData\Local\ESRI\conda\envs\arcgispro-py3-pyviz\lib\site-packages\bokeh\server\views\> exception=RuntimeError(‘Patched curdoc has been previously destroyed’)>)
Traceback (most recent call last):
File “C:\Users\mladmin\AppData\Local\ESRI\conda\envs\arcgispro-py3-pyviz\lib\site-packages\tornado\”, line 741, in _run_callback
ret = callback()
File “C:\Users\mladmin\AppData\Local\ESRI\conda\envs\arcgispro-py3-pyviz\lib\site-packages\tornado\”, line 765, in _discard_future_result
File “C:\Users\mladmin\AppData\Local\ESRI\conda\envs\arcgispro-py3-pyviz\lib\site-packages\bokeh\server\views\”, line 202, in _async_open
await self.application_context.create_session_if_needed(session_id, self.request, token)
File “C:\Users\mladmin\AppData\Local\ESRI\conda\envs\arcgispro-py3-pyviz\lib\site-packages\bokeh\server\”, line 243, in create_session_if_needed
File “C:\Users\mladmin\AppData\Local\ESRI\conda\envs\arcgispro-py3-pyviz\lib\site-packages\panel\io\”, line 206, in initialize_document
File “C:\Users\mladmin\AppData\Local\ESRI\conda\envs\arcgispro-py3-pyviz\lib\site-packages\bokeh\application\”, line 194, in initialize_document
File “C:\Users\mladmin\AppData\Local\ESRI\conda\envs\arcgispro-py3-pyviz\lib\site-packages\panel\io\”, line 414, in modify_document
old_doc = curdoc()
File “C:\Users\mladmin\AppData\Local\ESRI\conda\envs\arcgispro-py3-pyviz\lib\site-packages\bokeh\io\”, line 62, in curdoc
raise RuntimeError(“Patched curdoc has been previously destroyed”)
RuntimeError: Patched curdoc has been previously destroyed

I think this is an error that should be fixed with the latest release of Panel, i.e. 0.13.1. Which version are you running? Could you try with the latest version of Panel?

Out of curiosity, I see that the paths in the traceback you shared point to an installation of conda embedded within ArcGIS Pro. What’s the experience of developing Panel web apps like in this environment? Are these geo apps?

1 Like

version 13.0. Using panel to create dynamic forms based on different categories. The selected params are then sent to arcpy functions to export pdfs from ArcGIS pro. The pdf is then rendered in an iframe and the job history is then shown in a tabulator with an updated job status all filtered to the user in the session.

1 Like

Cool, that sounds pretty advanced! And yes I’d advise upgrading to 0.13.1 and see if the error goes away.

upgrading now. This is how I get user. Does it need to be parameter or is it fine just being a variable?

user = decode_signed_value(cookie_secret, “user”, secure_cookie).decode(“utf-8”)

That seems like a very different question. Could you open a new post and precise your question a little more? Someone from the community is more likely to respond rather than in this thread :slight_smile:

Well I upgraded version, will see if the error goes away and keep yall posted.