diff --git a/Python_script/MeasurementPlot.py b/Python_script/MeasurementPlot.py index ce3c796054ecbe34d9b0c2f73882f53f199bf95f..a1db17670863bf1458a9e6ae170acc740f0344e0 100644 --- a/Python_script/MeasurementPlot.py +++ b/Python_script/MeasurementPlot.py @@ -146,7 +146,8 @@ class MeasurementPlot: plt.rcParams.update({'font.size': 16}) - self.data_queue = mp.Queue(10) + ctx = mp.get_context('spawn') + self.data_queue = ctx.Queue(10) def stop(self): self.data_queue.put((None, None, True)) diff --git a/Python_script/climate-lab-gui.py b/Python_script/climate-lab-gui.py index 7ae0a073f8e2d13a515937f62c41afbb6bf659ac..b9f302b250bad77a6d08f50171268d1c439a59c5 100755 --- a/Python_script/climate-lab-gui.py +++ b/Python_script/climate-lab-gui.py @@ -107,14 +107,15 @@ class TestStandMainWindow(QMainWindow): elif self.measurementFileButton.isChecked(): measurement_type = 'file' - error_queue = mp.Queue(3) + ctx = mp.get_context('spawn') + error_queue = ctx.Queue(3) - p = mp.Process(target=TestStandMainWindow.do_measurement_impl, - args=(measurement_type, output_basename, self.startParameter.value(), self.stopParameter.value(), - self.stepParameter.value(), self.fixedParameter.value(), self.soakingTime.value(), - self.stableReads.value(), self.get_analysis_config(time_string), - os.path.join(self.start_dir, self.measurementFile.text()), error_queue, config_data, - ext_sensor_channels)) + p = ctx.Process(target=TestStandMainWindow.do_measurement_impl, + args=(measurement_type, output_basename, self.startParameter.value(), self.stopParameter.value(), + self.stepParameter.value(), self.fixedParameter.value(), self.soakingTime.value(), + self.stableReads.value(), self.get_analysis_config(time_string), + os.path.join(self.start_dir, self.measurementFile.text()), error_queue, config_data, + ext_sensor_channels)) p.start() while p.is_alive(): @@ -181,9 +182,6 @@ class TestStandMainWindow(QMainWindow): except FileNotFoundError as e: error_queue.put(str(e)) - except Exception as e: - print('ERROR: Exception during measurement: '+str(e)) - error_queue.put(str(e)) finally: if meas is not None: diff --git a/Python_script/process_sync.py b/Python_script/process_sync.py index 282d7c747407e0a531aa5b441905f401d64b6ce2..309c7229cf009fbf8db645055482cb056ef8f24b 100644 --- a/Python_script/process_sync.py +++ b/Python_script/process_sync.py @@ -1,4 +1,5 @@ import multiprocessing as mp # Global variables to be imported in multiple modules to avoid circular dependencies -stop_measurement = mp.Event() +ctx = mp.get_context('spawn') +stop_measurement = ctx.Event() diff --git a/Python_script/prototype.py b/Python_script/prototype.py index 1ddd6467fde3dc93d89b07fb38bfa2650616415d..675cf36b4dc5014b27cfe6922ec0cf92367ee468 100755 --- a/Python_script/prototype.py +++ b/Python_script/prototype.py @@ -13,7 +13,7 @@ import json import MeasurementPlot import sys import analysis -from multiprocessing import Process +import multiprocessing as mp import external_sensors import PostPlot import os @@ -176,10 +176,11 @@ class Measurements: measurement sets of this chamber point are taken for this measurement. """ process_sync.stop_measurement.clear() - measurement_process = Process(target=self.perform_single_measurement_impl, - args=(output, target_temp, target_hum, soaking_time, n_stable_reads)) + ctx = mp.get_context('spawn') + measurement_process = ctx.Process(target=self.perform_single_measurement_impl, + args=(output, target_temp, target_hum, soaking_time, n_stable_reads)) measurement_process.start() - #turn interactive plotting (back) on (is deactivated by starting the process) + # turn interactive plotting (back) on (is deactivated by starting the process) plt.ion() self.measurement_plot.drawing_loop() measurement_process.join() diff --git a/Python_script/shared_simulated_state.py b/Python_script/shared_simulated_state.py index 980ff7019fd8abf04ad0512e7725ab1cdebe285b..c8872a21ab7b557c256dbeed89a13f4051fa24e2 100644 --- a/Python_script/shared_simulated_state.py +++ b/Python_script/shared_simulated_state.py @@ -12,7 +12,7 @@ def get_simulated_state(): class SimulatedState: def __init__(self): - - self.simulated_time = mp.Value('d', 0.0) - self.simulated_temperature = mp.Value('d', 25.) - self.simulated_humidity = mp.Value('d', 35.) + ctx = mp.get_context('spawn') + self.simulated_time = ctx.Value('d', 0.0) + self.simulated_temperature = ctx.Value('d', 25.) + self.simulated_humidity = ctx.Value('d', 35.)