I've created an interactive app in my jupyter lab and called .show() on my panel object, so it started a bokeh server, as in the example below. It looks nice, but now I want to stop the server. How do I do that without stopping jupyter notebook or killing my python kernel? I don't want to restart my notebook kernel because I don't want to lose other variables present in my current notebook.
I just want to stop/kill that bokeh server that was initiated by .show()
import numpy as np
import pandas as pd
import hvplot.pandas
import holoviews as hv
import panel as pn
df = pd.DataFrame(np.random.normal(size=[50, 2]))
hv_plot = df.hvplot()
pn.panel(hv_plot).show(port=12345)
Maybe it's just best to declare the bokeh server as such:
bokeh_server = pn.panel(hv_plot).show(port=12345)
This way you have right away control over the server without having to look in your globals() to see where the server is.
You can stop the server as follows:
bokeh_server.stop()
The strange thing is, the address localhost:12345 can still be reached when you stop the server like this, and you can still use the app when you already had it open in your browser. However when you refresh the page it's gone and you can use the port again for a different app. It just takes quite a while before the server is completely stopped.