From a3b2380365e0142049b4faeb43f60a4a7c4dcfde Mon Sep 17 00:00:00 2001 From: Vinyl Darkscratch Date: Wed, 7 Mar 2018 00:43:08 -0800 Subject: [PATCH] Catch for game quit cleanup --- journal/unix/journal.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/journal/unix/journal.py b/journal/unix/journal.py index f0752a1..b4c539a 100644 --- a/journal/unix/journal.py +++ b/journal/unix/journal.py @@ -19,18 +19,20 @@ class WatchPipe(QThread): def run(self): while True: - if os.path.exists(pipe_path): break - else: time.sleep(0.1) + while True: + if os.path.exists(pipe_path): break + else: time.sleep(0.1) - pipe = open(pipe_path, 'r') - pipe.flush() + pipe = open(pipe_path, 'r') + pipe.flush() - while True: - message = os.read(pipe.fileno(), 256) - if len(message) > 0: - self.change_image.emit(message.decode()) + while True: + if not os.path.exists(pipe_path): break # Handle game quitting cleanup + message = os.read(pipe.fileno(), 256) + if len(message) > 0: + self.change_image.emit(message.decode()) - time.sleep(0.05) + time.sleep(0.05) class Journal(QWidget): def __init__(self, *args, **kwargs):