Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can only call write_image a certain number of times before process hangs #1255

Closed
slishak opened this issue Nov 2, 2018 · 6 comments
Closed
Labels
bug something broken
Milestone

Comments

@slishak
Copy link

slishak commented Nov 2, 2018

Using Orca to export multiple static PDF files, when I get to the 25th file the process hangs and never completes. The limiting number of files seems to depend on the file type:
pdf, svg: 24 files written
png, jpg, webp: 25 files written before hanging

The same happens whether I write to a file or a BytesIO stream. For interest, the reason I'm doing this is to write a multi-page PDF as per the issue here plotly/orca#143.

import plotly.io as pio
import plotly.graph_objs as go
import io
import numpy as np


def make_figure():
    """Function to make random figure"""
    x = np.linspace(0, 10, 100)
    y = np.random.randint(1, 100, 100)

    trace = go.Scatter(x=x, y=y, mode='markers')
    return go.Figure(data=[trace])


use_stream = False
filetype = 'pdf'

for i in range(50):
    print('Page {}'.format(i+1))

    if use_stream:
        pdf_file = io.BytesIO()
    else:
        pdf_file = '{}.{}'.format(i, filetype)

    pio.write_image(make_figure(), pdf_file, filetype)

I can circumvent the issue by adding the following line into the loop to periodically restart the Orca server:

    if (i+1) % 20 == 0:
        pio._orca.shutdown_server()

Versions:

Windows 7 Professional
Python 3.6.4 x64

plotly==3.3.0
psutil==5.4.8

Node.js v8.12.0
npm@6.4.1
electron@1.8.4
orca@1.1.1
@jonmmease
Copy link
Contributor

Hi @slishak, thanks very much for the detailed report. I will try to reproduce on a windows vm (although I only have access to windows 10). Out of curiosity, have you tried installing orca with conda or the windows installer? I don’t know that these would behave differently, but these version of orca have gone through the electron packing process.

@slishak
Copy link
Author

slishak commented Nov 2, 2018

Neither - I installed using npm and pip as per https://plot.ly/python/static-image-export/#npm--pip

@jonmmease jonmmease added the bug something broken label Nov 5, 2018
@jonmmease
Copy link
Contributor

I was able to reproduce this on my windows 10 VM and the number of exports at which the process hangs exactly matches your report. This does not hang on OS X or Linux even out to 1000 images 🤔

Next I'll try to reproduce without plotly.py

@jonmmease
Copy link
Contributor

Closed by #1262. Could you give the 3.4.1 release candidate a try and confirm that it fixes the issue for you? Installation instructions for the release candidate at https://github.com/plotly/plotly.py/tree/release_3.4.1

Thanks again for taking the time to to report this!

@slishak
Copy link
Author

slishak commented Nov 7, 2018

That appears to have done the trick, just wrote a 200 page PDF without having to restart Orca! Thanks for looking into it.

@jonmmease
Copy link
Contributor

Great! Thanks for giving the release candidate a try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

No branches or pull requests

2 participants