26 lines
925 B
Python
26 lines
925 B
Python
# workers.py
|
|
import flares
|
|
|
|
# This function must be completely standalone.
|
|
# No PyQt imports here!
|
|
def run_fold_process(haemo_obj, label, shared_dict):
|
|
"""
|
|
Runs in a separate OS process.
|
|
Writes progress to shared_dict so the GUI can see it.
|
|
"""
|
|
try:
|
|
def progress_callback(value):
|
|
# Only update shared memory if the value has changed
|
|
# This significantly reduces "noise" on the GUI thread
|
|
if shared_dict.get(label) != value:
|
|
shared_dict[label] = value
|
|
|
|
# Run the heavy calculation
|
|
# Ensure 'flares' logic does not try to open any plots/GUIs itself!
|
|
figures = flares.fold_channels(haemo_obj, progress_callback=progress_callback)
|
|
|
|
|
|
except Exception as e:
|
|
# If something breaks here, we return the error string
|
|
# so the main thread knows what happened.
|
|
return f"ERROR: {str(e)}" |