Skip to content

Commit

Permalink
Avoid race condition when displaying images with eog
Browse files Browse the repository at this point in the history
Image.show() expects its display command to run synchronously, but eog
is asynchronous if there's another instance already running -- it just
asks the other instance to open the file and then immediately exits.
This causes intermittent failures where the file gets deleted before
the running eog instance manages to open it.

Fix this by using the -n option, so eog starts a new instance each time
instead of trying to reuse an existing one.
  • Loading branch information
mconst committed May 23, 2021
1 parent cc2db17 commit 5c8aa27
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/PIL/ImageShow.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ class EogViewer(UnixViewer):
"""The GNOME Image Viewer ``eog`` command."""

def get_command_ex(self, file, **options):
command = executable = "eog"
executable = "eog"
command = "eog -n"
return command, executable


Expand Down

0 comments on commit 5c8aa27

Please sign in to comment.