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
Wait until executable has finished to remove file on Unix #6039
Conversation
Would it be a breaking change to instead change the returned value? I think it is quite unlikely that any code depends on the exact type of the returned value, since bool is a subclass of int: >>> False == 0
True
>>> True == 1
True
>>> True + True
2
>>> type(True)
<class 'bool'>
>>> issubclass(bool, int)
True |
You make a good argument. Ok, I've pushed that change. |
@radarhere I'm upvoting the idea of leaving file deletion to OS. It seems to be a valid solution. https://www.fosslinux.com/41739/linux-tmp-directory-everything-you-need-to-know.htm |
@alv2017 while we may end up choosing that option, I'm still interested to know - do you have any objections to this PR as it currently stands? |
@radarhere, I tested the changes manually on my machine, and
|
Here is my recording of it working with GmDisplayViewer for me. gm.movWhen you say that it fails, could you give some more detail? When you say that XDGViewer fails, what image viewer is it opening? |
Script to test multiple images: import os
from PIL import Image
from PIL.ImageShow import DisplayViewer, GmDisplayViewer, EogViewer, XDGViewer
if __name__ == "__main__":
viewer = XDGViewer()
img_dir = "/image/directory"
img_files = ["img1.png", "img2.png", "img3.png"]
for img_file in img_files:
img_location = os.path.join(img_dir, img_file)
with Image.open(img_location) as im:
viewer.show(im) |
Ok, the premise of my change - that commands like I've created PR #6045 instead. |
Helps #5945 and #5976. Alternative to #6021
Three changes here.
ImageShow.show()
does not returnTrue
andFalse
like the docstring states, it returns 0 and 1. So this PR updates the docstring.display -title
looks preferable todisplay -name
.Since
xdg-open
does not wait until the application is closed, this PR instead usesxdg-mime
to determine what application would be selected byxdg-open
, and executes it directly.For the record - I'm also not opposed to the suggested alternative of just abandoning the idea of manually deleting temporary files and leaving it up to the operating system.