lebedov / python-pdfbox

Python interface to Apache PDFBox command-line tools.
Other
75 stars 24 forks source link

Error: JVM is already started #21

Closed FPEPOSHI closed 4 years ago

FPEPOSHI commented 4 years ago

I'm getting an error: JVM is already started when I try to extract the text from pdf for the second time.

I can see that when PDFBox is constructed, you try to start JVM jpype.startJVM(convertStrings=False) and this gives an error when its already started. Is it better to use jpype.isJVMStarted() to check before you try to start JVM?

So, in my case, it will be better to check before starting it, because I use it for API calls and it will crash when I have 2 or more concurrent calls.

Possible fix for the constructor: if jpype.isJVMStarted() is False: jpype.startJVM(convertStrings=False)

lebedov commented 4 years ago

Good point. Fixed and updated version released.

FPEPOSHI commented 4 years ago

Thank you for your quick update.