Commit ecdfb77e authored by Roman Alifanov's avatar Roman Alifanov

all processes are terminated instantly when the window is closed

parent 914216a3
...@@ -3,11 +3,10 @@ import threading ...@@ -3,11 +3,10 @@ import threading
from gi.repository import GLib from gi.repository import GLib
class ApplicationManager: class ApplicationManager:
@staticmethod @staticmethod
def get_available_applications(callback): def get_available_applications(callback):
threading.Thread(target=ApplicationManager._get_available_applications, args=(callback,)).start() threading.Thread(target=ApplicationManager._get_available_applications, daemon=True, args=(callback,)).start()
@staticmethod @staticmethod
def _get_available_applications(callback): def _get_available_applications(callback):
...@@ -21,11 +20,11 @@ class ApplicationManager: ...@@ -21,11 +20,11 @@ class ApplicationManager:
else: else:
GLib.idle_add(callback, [], stderr) # Pass error message GLib.idle_add(callback, [], stderr) # Pass error message
threading.Thread(target=read_output).start() threading.Thread(target=read_output, daemon=True).start()
@staticmethod @staticmethod
def get_installed_applications(callback): def get_installed_applications(callback):
threading.Thread(target=ApplicationManager._get_installed_applications, args=(callback,)).start() threading.Thread(target=ApplicationManager._get_installed_applications, daemon=True, args=(callback,)).start()
@staticmethod @staticmethod
def _get_installed_applications(callback): def _get_installed_applications(callback):
...@@ -39,7 +38,7 @@ class ApplicationManager: ...@@ -39,7 +38,7 @@ class ApplicationManager:
else: else:
GLib.idle_add(callback, [], stderr) # Pass error message GLib.idle_add(callback, [], stderr) # Pass error message
threading.Thread(target=read_output).start() threading.Thread(target=read_output, daemon=True).start()
@staticmethod @staticmethod
def parse_applications_output(output): def parse_applications_output(output):
......
...@@ -3,7 +3,6 @@ import threading ...@@ -3,7 +3,6 @@ import threading
from gi.repository import GLib from gi.repository import GLib
class CommandRunner: class CommandRunner:
def __init__(self, on_done=None): def __init__(self, on_done=None):
self.dialog = None self.dialog = None
...@@ -32,20 +31,20 @@ class CommandRunner: ...@@ -32,20 +31,20 @@ class CommandRunner:
try: try:
process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, text=True) stderr=subprocess.PIPE, text=True)
threading.Thread(target=read_output, args=(process.stdout,)).start() threading.Thread(target=read_output, daemon=True, args=(process.stdout,)).start()
threading.Thread(target=read_output, args=(process.stderr,)).start() threading.Thread(target=read_output, daemon=True, args=(process.stderr,)).start()
process.wait() process.wait()
GLib.idle_add(dialog.close) GLib.idle_add(dialog.force_close)
if self.on_done: if self.on_done:
GLib.idle_add(self.on_done) # Call the callback function after completion GLib.idle_add(self.on_done) # Call the callback function after completion
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
GLib.idle_add(append_log, f"Ошибка: {str(e)}\n") GLib.idle_add(append_log, f"Ошибка: {str(e)}\n")
GLib.idle_add(dialog.close) GLib.idle_add(dialog.force_close)
if self.on_done: if self.on_done:
GLib.idle_add(self.on_done) # Call the callback function after completion GLib.idle_add(self.on_done) # Call the callback function after completion
threading.Thread(target=process_runner).start() threading.Thread(target=process_runner, daemon=True).start()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment