Skip to content

Commit f6bbdae

Browse files
authored
Add workaround for orca segmentation fault (#1140)
* Workaround for plotly/orca#124 Unset the NODE_OPTIONS environment variable before calling orca to avoid an orca segmentation fault * Constrain ipykernel version. Build was breaking on Python 2.7 with ipykernel 4.9 * Reconnect stream write on 502 errors Example test failure: ``` ====================================================================== ERROR: test_stream_single_points (plotly.tests.test_plot_ly.test_stream.test_stream.TestStreaming) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/circleci/project/plotly/tests/test_plot_ly/test_stream/test_stream.py", line 52, in test_stream_single_points my_stream.write(Scatter(x=[1], y=[10])) File "/home/circleci/project/plotly/plotly/plotly.py", line 704, in write self._stream.write(jdata, reconnect_on=reconnect_on) File "/home/circleci/project/plotly/plotly/chunked_requests/chunked_request.py", line 61, in write msg=response.read())) Exception: Server responded with status code: 502 and message: <html><body><h1>502 Bad Gateway</h1> The server returned an invalid or incomplete response. </body></html> ```
1 parent 091f4c1 commit f6bbdae

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

plotly/io/_orca.py

+7
Original file line numberDiff line numberDiff line change
@@ -911,6 +911,13 @@ def validate_executable():
911911
formatted_path=formatted_path,
912912
instructions=install_location_instructions))
913913

914+
# Clear NODE_OPTIONS environment variable
915+
# ---------------------------------------
916+
# When this variable is set, orca <v1.2 will have a segmentation fault
917+
# due to an electron bug.
918+
# See: https://github.com/electron/electron/issues/12695
919+
os.environ.pop('NODE_OPTIONS', None)
920+
914921
# Run executable with --help and see if it's our orca
915922
# ---------------------------------------------------
916923
invalid_executable_msg = """

plotly/plotly/chunked_requests/chunked_request.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def __init__(self, server, port=80, headers={}, url='/', ssl_enabled=False,
2525
self._ssl_verification_enabled = ssl_verification_enabled
2626
self._connect()
2727

28-
def write(self, data, reconnect_on=('', 200, )):
28+
def write(self, data, reconnect_on=('', 200, 502)):
2929
''' Send `data` to the server in chunk-encoded form.
3030
Check the connection before writing and reconnect
3131
if disconnected and if the response status code is in `reconnect_on`.

tox.ini

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ deps=
6161
pytest==3.5.1
6262
optional: numpy==1.11.3
6363
optional: ipython[all]==5.1.0
64+
optional: ipykernel==4.8.2
6465
optional: jupyter==1.0.0
6566
optional: pandas==0.19.2
6667
optional: scipy==0.18.1

0 commit comments

Comments
 (0)