I am starting a panel app using this sequence of API calls from within my python program:
template = pn.template.FastListTemplate(...)
template.servable()
server = template.show(port,address,threaded=True, websocket_origin=... )
server.join()
I would like to know what the correct, graceful way stop/exit the app is. So far I am using Ctrl-C twice (once does not succeed) but that feels like a dirty hack and it always shows a lengthy weird stack trace on the console or log.
Is it possible to add code so that hitting Ctrl-C or SIGINT will gracefully and without a stacktrace terminate the program?
I would also have thought this is something for which documentation should exist somewhere, but I was unable to find it.
Sadly the panel API documentation seems to be close to non-existent (at least online, did not look at the source code yet), which in my opinion is always a rather bad sign for a software package.
I couldn’t reproduce with
import panel as pn
col = pn.Column(pn.widgets.TextInput(name='A'), pn.widgets.TextInput(name='B'))
template = pn.template.FastListTemplate(main=[col])
server = template.show()
But can reproduce with threaded=True
python testing.py
Launching server at http://localhost:59403
^CTraceback (most recent call last):
File "/Users/ahuang/repos/lumen/testing.py", line 7, in <module>
server.join()
File "/Users/ahuang/miniconda3/envs/lumen/lib/python3.12/threading.py", line 1149, in join
self._wait_for_tstate_lock()
File "/Users/ahuang/miniconda3/envs/lumen/lib/python3.12/threading.py", line 1169, in _wait_for_tstate_lock
if lock.acquire(block, timeout):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyboardInterrupt
I think it’s unexpected so you may raise a Panel issue.
1 Like
Thank you! I will see what the response to an issue will be …
Hi @johann-petrak,
Sadly the panel API documentation seems to be close to non-existent (at least online, did not look at the source code yet), which in my opinion is always a rather bad sign for a software package.
This looks like it’s a recent bug in the docs build, see Several API reference docs are empty / missing content · Issue #7605 · holoviz/panel · GitHub. Contributions to Panel are welcome if you feel like looking into this 
Actually it seems the requirement to press Ctrl-C twice arises because I am including server.join() in my code.
With threaded=Yes, the documentation states that the thread is returned, so I wanted to wait for that thread to terminate with server.join(). However even without the join the app does NOT terminate!
It seems that panel registers something in the python exit code or something to do the joining by itself? This is unexpected and not documented, it seems.