Files
stand/hacks/patch_st_cp_stop.py
2022-05-19 10:32:02 +02:00

22 lines
347 B
Python

"""
Monkey patch the streamlit server to stop cherrypy upon its own stop
"""
import cherrypy
from streamlit.server.server import Server
old_fn = Server._on_stopped
def new_fn(*args, **kwargs):
print("exit cherrypy")
cherrypy.engine.exit()
print("exit streamlit")
return old_fn(*args, **kwargs)
Server._on_stopped = new_fn