Better fix for long running highlight workers
This commit is contained in:
parent
9a1f14d05c
commit
42cabace47
@ -122,8 +122,6 @@ def highlight_line(line):
|
|||||||
def highlight_for_diff(path, aliases):
|
def highlight_for_diff(path, aliases):
|
||||||
ans = []
|
ans = []
|
||||||
lines = lines_for_path(path)
|
lines = lines_for_path(path)
|
||||||
if len(lines) > 10000:
|
|
||||||
return ans
|
|
||||||
hd = highlight_data('\n'.join(lines), path, aliases)
|
hd = highlight_data('\n'.join(lines), path, aliases)
|
||||||
if hd is not None:
|
if hd is not None:
|
||||||
for line in hd.splitlines():
|
for line in hd.splitlines():
|
||||||
@ -135,6 +133,7 @@ def highlight_collection(collection, aliases=None):
|
|||||||
jobs = {}
|
jobs = {}
|
||||||
ans = {}
|
ans = {}
|
||||||
with concurrent.futures.ProcessPoolExecutor(max_workers=os.cpu_count()) as executor:
|
with concurrent.futures.ProcessPoolExecutor(max_workers=os.cpu_count()) as executor:
|
||||||
|
highlight_collection.processes = executor._processes
|
||||||
for path, item_type, other_path in collection:
|
for path, item_type, other_path in collection:
|
||||||
if item_type != 'rename':
|
if item_type != 'rename':
|
||||||
for p in (path, other_path):
|
for p in (path, other_path):
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
# License: GPL v3 Copyright: 2018, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPL v3 Copyright: 2018, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import signal
|
||||||
import sys
|
import sys
|
||||||
import warnings
|
import warnings
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
@ -508,6 +509,13 @@ help_text = 'Show a side-by-side diff of the specified files/directories'
|
|||||||
usage = 'file_or_directory_left file_or_directory_right'
|
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)
|
||||||
|
|
||||||
|
|
||||||
def main(args):
|
def main(args):
|
||||||
warnings.showwarning = showwarning
|
warnings.showwarning = showwarning
|
||||||
args, items = parse_args(args[1:], OPTIONS, usage, help_text, 'kitty +kitten diff')
|
args, items = parse_args(args[1:], OPTIONS, usage, help_text, 'kitty +kitten diff')
|
||||||
@ -530,6 +538,8 @@ def main(args):
|
|||||||
for message in showwarning.warnings:
|
for message in showwarning.warnings:
|
||||||
from kitty.utils import safe_print
|
from kitty.utils import safe_print
|
||||||
safe_print(message, file=sys.stderr)
|
safe_print(message, file=sys.stderr)
|
||||||
|
processes = getattr(highlight_collection, 'processes', ())
|
||||||
|
terminate_processes(tuple(processes))
|
||||||
if loop.return_code != 0:
|
if loop.return_code != 0:
|
||||||
if handler.report_traceback_on_exit:
|
if handler.report_traceback_on_exit:
|
||||||
print(handler.report_traceback_on_exit, file=sys.stderr)
|
print(handler.report_traceback_on_exit, file=sys.stderr)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user