Public Access
fix return-value/deprecated API bugs, accumulation lock leaks, code cleanup
- raise instead of silent None for unsupported operands and empty negation - validate before acquiring lock in Accumulation operators (no RLock leak) - Accumulation._copy_provenance helper, ADC_Result._copy_metadata for all result paths - shared _sandbox_stdout_redirect contextmanager for sandboxed scripts - TemperatureMonitor dead code removal (gtk helper, traceback, unused properties) - new unit tests incl. lock-freedom regression test - gitignore sphinx generated doc/_autosummary/ and doc/damaris/
This commit is contained in:
1 parent
91ade4376c
commit
f9d8de7697
26 files changed
+590
-236
No files matched your search
@@ -7,7 +7,7 @@ import traceback
|
||||
import logging
|
||||
import ast
|
||||
from damaris.data import Resultable
|
||||
from damaris.gui.ExperimentHandling import StopExperiment, _SandboxStdout
|
||||
from damaris.gui.ExperimentHandling import StopExperiment, _sandbox_stdout_redirect
|
||||
|
||||
logger = logging.getLogger("damaris.result_handling")
|
||||
|
||||
@@ -28,12 +28,13 @@ class ResultHandling(threading.Thread):
|
||||
|
||||
def run(self):
|
||||
# Redirect stdout/stderr so print() in sandboxed scripts goes to the GUI
|
||||
_orig_stdout = sys.stdout
|
||||
_orig_stderr = sys.stderr
|
||||
if self._log_callback is not None:
|
||||
sys.stdout = _SandboxStdout(self._log_callback)
|
||||
sys.stderr = _SandboxStdout(self._log_callback)
|
||||
with _sandbox_stdout_redirect(self._log_callback):
|
||||
self._run_script()
|
||||
else:
|
||||
self._run_script()
|
||||
|
||||
def _run_script(self):
|
||||
# execute it
|
||||
dataspace={}
|
||||
data_classes = __import__('damaris.data', dataspace, dataspace, ['*'])
|
||||
@@ -96,30 +97,26 @@ class ResultHandling(threading.Thread):
|
||||
traceback_file=None
|
||||
dataspace=None
|
||||
|
||||
# Restore stdout/stderr
|
||||
sys.stdout = _orig_stdout
|
||||
sys.stderr = _orig_stderr
|
||||
|
||||
def sleep(self, seconds):
|
||||
self.quit_flag.wait(seconds)
|
||||
if self.quit_flag.isSet():
|
||||
if self.quit_flag.is_set():
|
||||
raise StopExperiment
|
||||
|
||||
def __iter__(self):
|
||||
if self.quit_flag.isSet():
|
||||
if self.quit_flag.is_set():
|
||||
self.results=None
|
||||
return
|
||||
for i in self.results:
|
||||
if hasattr(self.results, "in_advance"):
|
||||
self.data_space["__resultsinadvance"]=self.results.in_advance
|
||||
if self.quit_flag.isSet():
|
||||
if self.quit_flag.is_set():
|
||||
self.results=None
|
||||
return
|
||||
if isinstance(i, Resultable.Resultable):
|
||||
if self.data_space is not None:
|
||||
self.data_space["__recentresult"]=i.job_id+0
|
||||
yield i
|
||||
if self.quit_flag.isSet():
|
||||
if self.quit_flag.is_set():
|
||||
self.results=None
|
||||
return
|
||||
|
||||
|
||||
Reference in new issue
Block a user