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

Function ensure_server

plotly/io/_orca.py:1229–1330  ·  view source on GitHub ↗

Start an orca server if none is running. If a server is already running, then reset the timeout countdown Returns ------- None

()

Source from the content-addressed store, hash-verified

1227
1228# Launch or get server
1229def ensure_server():
1230 """
1231 Start an orca server if none is running. If a server is already running,
1232 then reset the timeout countdown
1233
1234 Returns
1235 -------
1236 None
1237 """
1238
1239 # Validate psutil
1240 if psutil is None:
1241 raise ValueError(
1242 """\
1243Image generation requires the psutil package.
1244
1245Install using pip:
1246 $ pip install psutil
1247
1248Install using conda:
1249 $ conda install psutil
1250"""
1251 )
1252
1253 # Validate requests
1254 if not get_module("requests"):
1255 raise ValueError(
1256 """\
1257Image generation requires the requests package.
1258
1259Install using pip:
1260 $ pip install requests
1261
1262Install using conda:
1263 $ conda install requests
1264"""
1265 )
1266
1267 if not config.server_url:
1268 # Validate orca executable only if server_url is not provided
1269 if status.state == "unvalidated":
1270 validate_executable()
1271 # Acquire lock to make sure that we keep the properties of orca_state
1272 # consistent across threads
1273 with orca_lock:
1274 # Cancel the current shutdown timer, if any
1275 if orca_state["shutdown_timer"] is not None:
1276 orca_state["shutdown_timer"].cancel()
1277
1278 # Start a new server process if none is active
1279 if orca_state["proc"] is None:
1280 # Determine server port
1281 if config.port is None:
1282 orca_state["port"] = find_open_port()
1283 else:
1284 orca_state["port"] = config.port
1285
1286 # Build orca command list

Callers 2

to_imageFunction · 0.85

Calls 6

get_moduleFunction · 0.90
validate_executableFunction · 0.85
find_open_portFunction · 0.85
orca_envFunction · 0.85
extendMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected