question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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 https://github.com/plotly/orca/issues/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

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
slishakcommented, 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.

1reaction
slishakcommented, Nov 2, 2018

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is my PHP script stopping when generating thumbnails?
Store the images to a "thumbnail" directory and then just load them like you normally would via tags. TADA problem solved. You only...
Read more >
Windows 10 Command Prompt: Running Programs freeze ...
This is a pretty old question but I was having this issue and found the answer: Command prompt hangs until keypress?
Read more >
ProcDump - Sysinternals - Microsoft Learn
This command-line utility is aimed at capturing process dumps of otherwise difficult to isolate and reproduce CPU spikes.
Read more >
[Guide] Training in Faceswap - Faceswap Forum
This forum is for discussing tips and understanding the process involved ... The model then repeats this action many, many times constantly ...
Read more >
Python Multithreading and Multiprocessing Tutorial - Toptal
Threading is just one of the many ways concurrent programs can be built. ... It blocks until there is an item in the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found