Correct fix for ignoring BrokenPipeError

This commit is contained in:
Kovid Goyal 2019-02-02 15:47:13 +05:30
parent d5d1e6c11e
commit 8778cf63c4
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 13 additions and 3 deletions

View File

@ -106,6 +106,7 @@ class Boss:
def __init__(self, os_window_id, opts, args, cached_values, new_os_window_trigger):
set_draw_minimal_borders(opts)
self.update_check_process = None
self.window_id_map = WeakValueDictionary()
self.startup_colors = {k: opts[k] for k in opts if isinstance(opts[k], Color)}
self.startup_cursor_text_color = opts.cursor_text_color
@ -778,6 +779,7 @@ class Boss:
def destroy(self):
self.shutting_down = True
self.child_monitor.shutdown_monitor()
self.update_check_process = None
del self.child_monitor
for tm in self.os_window_map.values():
tm.destroy()
@ -992,8 +994,6 @@ class Boss:
from .update_check import process_current_release
try:
raw = update_check_process.stdout.read().decode('utf-8')
except BrokenPipeError:
pass
except Exception as e:
log_error('Failed to read data from update check process, with error: {}'.format(e))
else:

View File

@ -96,11 +96,21 @@ def process_current_release(raw):
notify_new_version(release_version)
def run_worker():
import time
import random
time.sleep(random.randint(1000, 4000) / 1000)
try:
print(get_released_version())
except BrokenPipeError:
pass # happens if parent process is killed before us
def update_check(timer_id=None):
try:
p = subprocess.Popen([
kitty_exe(), '+runpy',
'from kitty.update_check import *; import time, random; time.sleep(random.randint(1000, 4000) / 1000); print(get_released_version())'
'from kitty.update_check import run_worker; run_worker()'
], stdout=subprocess.PIPE)
except EnvironmentError as e:
log_error('Failed to run kitty for update check, with error: {}'.format(e))