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

Function request_image_with_retrying

plotly/io/_orca.py:1334–1359  ·  view source on GitHub ↗

Helper method to perform an image request to a running orca server process with retrying logic.

(**kwargs)

Source from the content-addressed store, hash-verified

1332
1333@retry(min_wait=5, max_wait=10, max_delay=60000)
1334def request_image_with_retrying(**kwargs):
1335 """
1336 Helper method to perform an image request to a running orca server process
1337 with retrying logic.
1338 """
1339 from requests import post
1340 from plotly.io.json import to_json_plotly
1341
1342 if config.server_url:
1343 server_url = config.server_url
1344 else:
1345 server_url = "http://{hostname}:{port}".format(
1346 hostname="localhost", port=orca_state["port"]
1347 )
1348
1349 request_params = {k: v for k, v in kwargs.items() if v is not None}
1350 json_str = to_json_plotly(request_params)
1351 response = post(server_url + "/", data=json_str)
1352
1353 if response.status_code == 522:
1354 # On "522: client socket timeout", return server and keep trying
1355 shutdown_server()
1356 ensure_server()
1357 raise OSError("522: client socket timeout")
1358
1359 return response
1360
1361
1362def to_image(fig, format=None, width=None, height=None, scale=None, validate=True):

Callers 1

to_imageFunction · 0.85

Calls 5

to_json_plotlyFunction · 0.90
shutdown_serverFunction · 0.85
ensure_serverFunction · 0.85
formatMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected