changelog fixes and further updates to cancel running process

This commit is contained in:
2025-10-15 10:48:07 -07:00
parent 87073fb218
commit d6c71e0ab2
2 changed files with 59 additions and 1 deletions

54
main.py
View File

@@ -1178,6 +1178,11 @@ class ProgressBubble(QWidget):
rect.setStyleSheet("background-color: yellow; border: 1px solid gray;")
else:
rect.setStyleSheet("background-color: white; border: 1px solid gray;")
def mark_cancelled(self):
if 0 <= self.current_step < len(self.rects):
rect = self.rects[self.current_step]
rect.setStyleSheet("background-color: red; border: 1px solid gray;")
def mousePressEvent(self, event):
self.clicked.emit(self)
@@ -3606,6 +3611,7 @@ class MainApplication(QMainWindow):
self.param_sections = []
self.folder_paths = []
self.section_widget = None
self.first_run = True
self.init_ui()
self.create_menu_bar()
@@ -3875,6 +3881,8 @@ class MainApplication(QMainWindow):
def clear_all(self):
self.cancel_task()
self.right_column_widget.hide()
# Clear the bubble layout
@@ -4284,8 +4292,52 @@ class MainApplication(QMainWindow):
return self.file_metadata
def cancel_task(self):
self.button1.clicked.disconnect(self.cancel_task)
self.button1.setText("Stopping...")
if hasattr(self, "result_process") and self.result_process.is_alive():
parent = psutil.Process(self.result_process.pid)
children = parent.children(recursive=True)
for child in children:
try:
child.kill()
except psutil.NoSuchProcess:
pass
self.result_process.terminate()
self.result_process.join()
if hasattr(self, "result_timer") and self.result_timer.isActive():
self.result_timer.stop()
# if hasattr(self, "result_process") and self.result_process.is_alive():
# self.result_process.terminate() # Forcefully terminate the process
# self.result_process.join() # Wait for it to properly close
# # Stop the QTimer if running
# if hasattr(self, "result_timer") and self.result_timer.isActive():
# self.result_timer.stop()
for bubble in self.bubble_widgets.values():
bubble.mark_cancelled()
self.statusbar.showMessage("Processing cancelled.")
self.button1.clicked.connect(self.on_run_task)
self.button1.setText("Process")
'''MODULE FILE'''
def on_run_task(self):
self.button1.clicked.disconnect(self.on_run_task)
self.button1.setText("Cancel")
self.button1.clicked.connect(self.cancel_task)
if not self.first_run:
for bubble in self.bubble_widgets.values():
bubble.mark_cancelled()
self.first_run = False
# Collect all selected snirf files in a flat list
snirf_files = []
@@ -4327,7 +4379,7 @@ class MainApplication(QMainWindow):
self.manager = Manager()
self.result_queue = self.manager.Queue()
self.progress_queue = self.manager.Queue()
self.result_process = Process(
target=run_gui_entry_wrapper,
args=(collected_data, self.result_queue, self.progress_queue)