MCPcopy Index your code
hub / github.com/plotly/plotly.py / shutdown_server

Function shutdown_server

plotly/io/_orca.py:1175–1225  ·  view source on GitHub ↗

Shutdown the running orca server process, if any Returns ------- None

()

Source from the content-addressed store, hash-verified

1173
1174
1175def shutdown_server():
1176 """
1177 Shutdown the running orca server process, if any
1178
1179 Returns
1180 -------
1181 None
1182 """
1183 # Use double-check locking to make sure the properties of orca_state
1184 # are updated consistently across threads.
1185 if orca_state["proc"] is not None:
1186 with orca_lock:
1187 if orca_state["proc"] is not None:
1188 # We use psutil to kill all child processes of the main orca
1189 # process. This prevents any zombie processes from being
1190 # left over, and it saves us from needing to write
1191 # OS-specific process management code here.
1192
1193 parent = psutil.Process(orca_state["proc"].pid)
1194 for child in parent.children(recursive=True):
1195 try:
1196 child.terminate()
1197 except Exception:
1198 # We tried, move on
1199 pass
1200
1201 try:
1202 # Kill parent process
1203 orca_state["proc"].terminate()
1204
1205 # Wait for the process to shutdown
1206 orca_state["proc"].wait()
1207 except Exception:
1208 # We tried, move on
1209 pass
1210
1211 # Update our internal process management state
1212 orca_state["proc"] = None
1213
1214 if orca_state["shutdown_timer"] is not None:
1215 orca_state["shutdown_timer"].cancel()
1216 orca_state["shutdown_timer"] = None
1217
1218 orca_state["port"] = None
1219
1220 # Update orca.status so the user has an accurate view
1221 # of the state of the orca server
1222 status._props["state"] = "validated"
1223 status._props["pid"] = None
1224 status._props["port"] = None
1225 status._props["command"] = None
1226
1227
1228# Launch or get server

Callers 8

server_urlMethod · 0.85
timeoutMethod · 0.85
topojsonMethod · 0.85
mathjaxMethod · 0.85
mapbox_access_tokenMethod · 0.85
reset_statusFunction · 0.85
cleanupFunction · 0.85

Calls 1

childrenMethod · 0.45

Tested by

no test coverage detected