mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-07 17:43:53 +02:00
Also prevent long running diff workers from causing a hang on exit
This commit is contained in:
@@ -25,7 +25,7 @@ from .collect import (
|
||||
set_highlight_data
|
||||
)
|
||||
from .config import init_config
|
||||
from .patch import Differ, set_diff_command
|
||||
from .patch import Differ, set_diff_command, worker_processes
|
||||
from .render import ImageSupportWarning, LineRef, render_diff
|
||||
from .search import BadRegex, Search
|
||||
|
||||
@@ -511,9 +511,10 @@ usage = 'file_or_directory_left file_or_directory_right'
|
||||
|
||||
def terminate_processes(processes):
|
||||
for pid in processes:
|
||||
os.kill(pid, signal.SIGTERM)
|
||||
for pid in processes:
|
||||
os.kill(pid, signal.SIGKILL)
|
||||
try:
|
||||
os.kill(pid, signal.SIGKILL)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
def main(args):
|
||||
@@ -538,8 +539,9 @@ def main(args):
|
||||
for message in showwarning.warnings:
|
||||
from kitty.utils import safe_print
|
||||
safe_print(message, file=sys.stderr)
|
||||
processes = getattr(highlight_collection, 'processes', ())
|
||||
terminate_processes(tuple(processes))
|
||||
highlight_processes = getattr(highlight_collection, 'processes', ())
|
||||
terminate_processes(tuple(highlight_processes))
|
||||
terminate_processes(tuple(worker_processes))
|
||||
if loop.return_code != 0:
|
||||
if handler.report_traceback_on_exit:
|
||||
print(handler.report_traceback_on_exit, file=sys.stderr)
|
||||
|
||||
Reference in New Issue
Block a user