Skip to content

Commit

Permalink
Add workaround for orca segmentation fault (#1140)
Browse files Browse the repository at this point in the history
* 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>
```
  • Loading branch information
jonmmease authored Aug 30, 2018
1 parent 091f4c1 commit f6bbdae
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions plotly/io/_orca.py
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,13 @@ def validate_executable():
formatted_path=formatted_path,
instructions=install_location_instructions))

# Clear NODE_OPTIONS environment variable
# ---------------------------------------
# When this variable is set, orca <v1.2 will have a segmentation fault
# due to an electron bug.
# See: https://github.com/electron/electron/issues/12695
os.environ.pop('NODE_OPTIONS', None)

# Run executable with --help and see if it's our orca
# ---------------------------------------------------
invalid_executable_msg = """
Expand Down
2 changes: 1 addition & 1 deletion plotly/plotly/chunked_requests/chunked_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __init__(self, server, port=80, headers={}, url='/', ssl_enabled=False,
self._ssl_verification_enabled = ssl_verification_enabled
self._connect()

def write(self, data, reconnect_on=('', 200, )):
def write(self, data, reconnect_on=('', 200, 502)):
''' Send `data` to the server in chunk-encoded form.
Check the connection before writing and reconnect
if disconnected and if the response status code is in `reconnect_on`.
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ deps=
pytest==3.5.1
optional: numpy==1.11.3
optional: ipython[all]==5.1.0
optional: ipykernel==4.8.2
optional: jupyter==1.0.0
optional: pandas==0.19.2
optional: scipy==0.18.1
Expand Down

0 comments on commit f6bbdae

Please sign in to comment.