Skip to content
Snippets Groups Projects
Commit 68bfec4f authored by Martin Killenberg's avatar Martin Killenberg
Browse files

chore: move to spawn

parent 9c1a71aa
No related branches found
No related tags found
No related merge requests found
......@@ -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))
......
......@@ -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:
......
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()
......@@ -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()
......
......@@ -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.)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment