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

LibreOffice gets stuck #189

Closed
dvandersluis opened this issue Feb 24, 2014 · 7 comments
Closed

LibreOffice gets stuck #189

dvandersluis opened this issue Feb 24, 2014 · 7 comments

Comments

@dvandersluis
Copy link
Contributor

Sometimes the instance of LibreOffice opened by unoconv gets "stuck" (in that it doesn't so anything and doesn't close either), even though I'm using the -T (timeout) option when initializing unoconv. The unoconv process doesn't terminate either, until I kill LibreOffice.

Is there any way to detect if the listener has frozen (or whatever's actually going on), and have unoconv kill it once the timeout expires (assuming I'm not using a permanent listener, which I'm not), or at least exit with some sort of error that I could handle myself (a PID would be helpful)?

@oburlaca
Copy link

Hello dvandersluis,
Surprisingly, yesterday we had the same question as you:

We're processing lots of doc, docx files, yes, we know LibreOffice is not ideal, and may sometimes just block, eating 100% CPU, sometimes it crashes.

The question is: are their some best practices on how to use unoconv/LibreOffice:

  • to handle situations when LibreOffice is blocked at 100% CPU, and consequently unoconv not returning

.. I presume we should manually write watchdogs, do our own checks by PID etc?

@roozgar
Copy link

roozgar commented Feb 24, 2014

how can i get the libreoffice process manually in ubuntu shell!?

On Tue, Feb 25, 2014 at 1:33 AM, oburlaca notifications@github.com wrote:

Hello dvandersluis,
Surprisingly, yesterday we had the same question as you:

We're processing lots of doc, docx files, yes, we know LibreOffice is not
ideal, and may sometimes just block, eating 100% CPU, sometimes it crashes.

The question is: are their some best practices on how to use
unoconv/LibreOffice:

  • to handle situations when LibreOffice is blocked at 100% CPU, and
    consequently unoconv not returning

.. I presume we should manually write watchdogs, do our own checks by PID
etc?


Reply to this email directly or view it on GitHubhttps://github.com//issues/189#issuecomment-35945024
.

@dvandersluis
Copy link
Contributor Author

As an update, it seems that the listener is not actually necessarily stuck, but that it goes to sleep and doesn't get closed by unoconv. If I start unoconv again with a different port and using a different environment (as per http://ask.libreoffice.org/en/question/14841/how-can-i-use-soffice-from-the-command-line-when-quickstarter-is-running/?answer=29735#post-id-29735) I can continue to convert, despite the original listener still sticking around.

Of course, since I'm running this automatically via a script, and not babysitting it, without some sort of solution I'll end up with a ton of sleeping soffice processes that will never be used or closed, so any assistance would be appreciated. 😄

@lorenzyannick
Copy link

any news about that ?
I have the same issue and I didn't find why it happens.
Thx

@imkarthikk
Copy link

Do you think killing soffice.bin every time a unoconv process is starting solve this issue?

@dagwieers
Copy link
Member

@imkarthikk Normally unoconv takes great care in killing the soffice it spawned itself for the conversion (except if we use an existing listener, or if there was another user of the running listener), so there shouldn't be a need to kill it. However, if it gets stuck and unoconv is interrupted, the started listener may still be around.

So maybe it makes sense to do it just to be sure, however the real fix is to reproduce this and open an bug in the LibreOffice bug-tracker. If it is reproducable, you may want to test if LibreOffice can handle the file properly.

@gdott9
Copy link

gdott9 commented May 29, 2019

Hello @dagwieers ,

I have the same problem with the LibreOffice process and I have a question about the die method.

On unoconv#L1264, ooprc.wait() is called.
I'm not really familiar with Python but if I understand the documentation, it will wait indefinitely for the process to end. So, if the soffice.bin process is stuck, it will never go past this line and will never call ooprc.kill() (or os.kill(ooproc.pid, 9)).

Since Python 3.3, Popen.wait has a timeout option. But to support previous version of Python, should unoconv#L1264 and unoconv#L1270 be replaced by something like the following lines of code ?

start = time.time()
timeout = 30
while time.time() - start < timeout:
    time.sleep(0.1)
    if ooproc.poll() != None:
        break

With this code, it will wait and if after 30 seconds the libreoffice process is still running, it will try to kill it.

What do you think about this ?

@regebro regebro closed this as completed Nov 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants