plotly / orca

Command line application for generating static images of interactive plotly charts
MIT License
292 stars 40 forks source link

shutdown_server() ignoring server process state #372

Open eth42 opened 3 years ago

eth42 commented 3 years ago

Hi all,

I am using plotly 4.9.0 installed via pip and orca 1.3.1 installed via npm running on Windows 10. Whenever I invoke any call to orca in a fresh python kernel (currently 3.8.3), I encounter lots of errors suggesting that the communication between plotly and the orca server does not work (see error log below). I followed the steps suggested by Antoine in issue #279 (link to his reply) to separate the orca server start from the python kernel (i.e. start orca in terminal, connect with Plotly later) and observed that setting plotly.io.orca.config.server_url fails when attempting to shutdown the previously running server with a PID not found error. Manually overwriting the plotly.io._orca.orca_state dictionary to {"proc":None,"shutdown_timer":None} solves the issue as plotly forgets, that it is supposed to have an orca server, though this is quite the hack. My suggestion would be to catch any psutil.NoSuchProcess exception when trying to access the previous server and just assume, that the previous server has been dealt with in some other way, though I am not sure, whether this solves the issue at hand or just hides it. At least in the task manager I could not find the corresponding PID from which I would deduce, that the process died quietly. If you need further diagnostics on the issue just ask away. Having to resort to hacks, like overwriting internal states, to use the package is possible yet somewhat cumbersome.

Cheers Erik

Corresponding error log: error_log.txt

nicolaskruchten commented 3 years ago

Have you tried switching from Orca to Kaleido for static image export? It's much easier to manage and avoids this kind of issue :)

eth42 commented 3 years ago

Not yet, will take a look at it in the future. To be honest, I mostly copy-pasted examples from the plotly docs together (where I seemingly stumbled upon some older pages). I didn't notice, that plotly moved from orca to kaleido yet. Thanks for the advice.

Edit: Just made a quick test, works like a charm.