From 5c8aa277cebe3a71fc116c3ad416621f3e62cdec Mon Sep 17 00:00:00 2001 From: Michael Constant Date: Sat, 22 May 2021 23:56:44 -0700 Subject: [PATCH] Avoid race condition when displaying images with eog 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. --- src/PIL/ImageShow.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/PIL/ImageShow.py b/src/PIL/ImageShow.py index 0c6b9dc985a..c3693eb61f4 100644 --- a/src/PIL/ImageShow.py +++ b/src/PIL/ImageShow.py @@ -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