-
Notifications
You must be signed in to change notification settings - Fork 359
Conversation
Replace gs subprocess call Update requirements.txt
There is a problem: when we use the API the file descriptor remains open, even if we delete the resulting object. Seems to be a descriptor leak. https://gitlab.com/pdftools/python-ghostscript/issues/13 |
@KOLANICH Thanks for finding and reporting the python-ghostscript issue! Looks like python-ghostscript isn't being maintained actively, the last commit was 9 months ago. Maybe we can start a fork and try to fix the issue ourselves. Do you have any other recommendations? |
Another fix (like I mentioned in the #152) would be to remove ghostscript altogether, looking for pure Python packages that can convert a PDF into an image, without any tests failing. |
The last public commit of the author (in another repo) is on July, 2018.
1 I guess it makes no sense to fork (in the sense of hitting of a fork button) untill you have a patch ready to be merged back. |
Makes sense. Did you try |
@KOLANICH How do you check if the file descriptor is still open after you delete the gs instance as shown in the issue? |
The file cannot be deleted untill the interpreter is closed. |
Codecov Report
@@ Coverage Diff @@
## master #133 +/- ##
=========================================
+ Coverage 86.48% 86.98% +0.5%
=========================================
Files 13 13
Lines 1509 1491 -18
Branches 349 343 -6
=========================================
- Hits 1305 1297 -8
+ Misses 144 137 -7
+ Partials 60 57 -3
Continue to review full report at Codecov.
|
@KOLANICH I don't face any error while deleting the output file while the interpreter is open. I ran the code from your issue in one terminal and tried to delete the output file from another terminal (which was successful). Am I missing any step? I've vendorized the ghostscript code within an On a separate note, I use the |
I've vendorized this library since the latest stable version isn't available in Anaconda. |
Do you use Windows or Linux? On Linux you can delete an opened file, it disappears from fs, but its space is freed only after the descriptor is freed. On Windows an opened (without taking special measures) file simply cannot be deleted. |
Why not to create an own package? Vendorizing is bloat. |
I'm on WSL, which is essentially Linux. I didn't take the space being freed into account. Will try on Windows without any special measures.
That is why I kept only the code that is absolutely needed. Will submit a conda recipe to conda-forge when I get time, and remove this vendorized code when it gets accepted. |
I was able to delete the PDF file in use from the file explorer, anaconda prompt and powershell on Windows when using the |
This is a cleaner way to interact with the ghostscript, need to see if this PyPI package is available in anaconda or not. Also need to suppress the unnecessary logs generated by ghostscript.
EDIT: If it isn't available, maybe we could vendorize it.
Closes #152.