Kill in-flight tools instantly on quit via killpg(self)
When eris quits, _python_exit joins executor threads, which block on in-flight subprocess.run calls for up to TIMEOUT seconds. After saving state, kill the process group to reap all tool subprocesses instantly. Isolate editor/xdg-open in their own sessions so they survive.
This commit is contained in:
parent
eebb226b21
commit
87813fdf21
1 changed files with 6 additions and 2 deletions
|
|
@ -791,7 +791,8 @@ class Screen:
|
||||||
self._log.log_message([in_green("Editing "), path_colored,
|
self._log.log_message([in_green("Editing "), path_colored,
|
||||||
in_green(f" at line {line_num}…")])
|
in_green(f" at line {line_num}…")])
|
||||||
subprocess.Popen(f"{self.editor_command} +{line_num} {path}", shell=True,
|
subprocess.Popen(f"{self.editor_command} +{line_num} {path}", shell=True,
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
||||||
|
start_new_session=True)
|
||||||
def patch_file(self):
|
def patch_file(self):
|
||||||
result = self._summary.get_selection()
|
result = self._summary.get_selection()
|
||||||
if hasattr(result.tool, "patch_command") and result.tool.patch_command is not None:
|
if hasattr(result.tool, "patch_command") and result.tool.patch_command is not None:
|
||||||
|
|
@ -849,7 +850,8 @@ class Screen:
|
||||||
path = self._summary.get_selection().path
|
path = self._summary.get_selection().path
|
||||||
path_colored = lscolors.path_colored(path)
|
path_colored = lscolors.path_colored(path)
|
||||||
self._log.log_message([in_green("Opening "), path_colored, in_green("…")])
|
self._log.log_message([in_green("Opening "), path_colored, in_green("…")])
|
||||||
subprocess.Popen(["xdg-open", path], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
subprocess.Popen(["xdg-open", path], stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
||||||
|
start_new_session=True)
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
worker.Worker.unsaved_jobs_total = 0
|
worker.Worker.unsaved_jobs_total = 0
|
||||||
|
|
@ -1077,6 +1079,8 @@ async def main(title, root_path, worker_count=None, editor_command=None, theme=N
|
||||||
notifier.stop()
|
notifier.stop()
|
||||||
if summary.is_loaded:
|
if summary.is_loaded:
|
||||||
screen.save()
|
screen.save()
|
||||||
|
if sys.stdout.isatty() and os.getpgrp() == os.getpid():
|
||||||
|
os.killpg(os.getpgrp(), signal.SIGKILL)
|
||||||
|
|
||||||
|
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue