From 01e448105c15c7f9b1eb244abf7ace8f10ddf576 Mon Sep 17 00:00:00 2001 From: payno <henri.payno@esrf.fr> Date: Mon, 2 Oct 2023 10:29:56 +0200 Subject: [PATCH] DarkRefCopyProcessStack: improve robustness when lbsram gets full close #982 Signed-off-by: payno <henri.payno@esrf.fr> --- .../stacks/reconstruction/dkrefcopy.py | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/tomwer/synctools/stacks/reconstruction/dkrefcopy.py b/tomwer/synctools/stacks/reconstruction/dkrefcopy.py index 893fb40451..221aaa9e27 100644 --- a/tomwer/synctools/stacks/reconstruction/dkrefcopy.py +++ b/tomwer/synctools/stacks/reconstruction/dkrefcopy.py @@ -52,7 +52,12 @@ class DarkRefCopyProcessStack(FIFO, qt.QObject): """Signal emit when dark or flat are set by a scan. str is the scan identifier""" def __init__(self, process_id=None): - self._save_dir = tempfile.mkdtemp() + try: + self._save_dir = tempfile.mkdtemp() + except Exception as e: + _logger.warning( + f"unable to create save dir. Error is {e}. Won't be able to copy any dark or flat" + ) qt.QObject.__init__(self) FIFO.__init__(self, process_id=process_id) @@ -81,14 +86,20 @@ class DarkRefCopyProcessStack(FIFO, qt.QObject): self._data_currently_computed = data if isOnLbsram(data) and isLowOnMemory(get_lbsram_path()) is True: # if computer is running into low memory on lbsram skip it - mess = "low memory, skip dk-ref-copy", data.path - ProcessManager().notify_dataset_state( - dataset=data, process=self._process_id, state=DatasetState.SKIPPED - ) - _logger.processSkipped(mess) - if callback is not None: - callback() - self.scan_ready(scan=data) + mess = "low memory, skip dk-flat-copy", data.path + try: + ProcessManager().notify_dataset_state( + dataset=data, process=self, state=DatasetState.SKIPPED + ) + _logger.processSkipped(mess) + if callback is not None: + callback() + except Exception as e: + _logger.error(e) + try: + FIFO._end_threaded_computation(self) + except Exception as e: + _logger.error(e) else: self._data_currently_computed = data self._computationThread.init(data=data, inputs=configuration) -- GitLab