Avoid race condition when displaying images with eog #5507
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
First of all, thanks for maintaining Pillow all these years!
When Image.show() displays an image on Linux using eog, there's a race condition where the file can get deleted before eog opens it.
To reproduce this, you'll need a Linux system without imagemagick or graphicsmagick installed. Then you can make it happen pretty reliably, just by calling Image.show() several times:
With imagemagick installed, this correctly displays four green boxes. But if you're using eog, usually several of the images will give error messages like "No images found in file:///tmp/tmprt8btbpr.PNG" instead.
This happens because Image.show() expects its display command to run synchronously, but in fact eog runs asynchronously if another eog instance is already running -- it just asks the other instance to open the file and then immediately exits. The fix is to use eog -n instead, which forces it to always start a new instance.