From d07c93aee7ce373cb38a880ae2bf00cd087dc1c0 Mon Sep 17 00:00:00 2001 From: Jan David Mol <mol@astron.nl> Date: Fri, 6 Dec 2024 12:33:09 +0000 Subject: [PATCH] Do not go to FAULT on a read error --- README.md | 3 ++- attribute_wrapper/attribute_wrapper.py | 2 -- attribute_wrapper/decorators.py | 27 -------------------------- 3 files changed, 2 insertions(+), 30 deletions(-) delete mode 100644 attribute_wrapper/decorators.py diff --git a/README.md b/README.md index 44ed183..f2b18af 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,7 @@ This project is licensed under the Apache License Version 2.0 ## Releases -- 0.3 - Do not go to FAULT if a read or write fails +- 0.3.1 - Do not go to FAULT if a read fails +- 0.3 - Do not go to FAULT if a write fails - 0.2 - Ensure requirements.txt dependencies are installed - 0.1 - Initial release from separating into own repository diff --git a/attribute_wrapper/attribute_wrapper.py b/attribute_wrapper/attribute_wrapper.py index 63bb4c6..73513b2 100644 --- a/attribute_wrapper/attribute_wrapper.py +++ b/attribute_wrapper/attribute_wrapper.py @@ -9,7 +9,6 @@ from tango import AttrWriteType, AttReqType from tango.server import attribute from attribute_wrapper.attribute_io import AttributeIO -from attribute_wrapper.decorators import fault_on_error __all__ = ["AttributeWrapper"] @@ -138,7 +137,6 @@ class AttributeWrapper(attribute): else: """Assign the read function to the attribute""" - @fault_on_error() def read_func_wrapper(device): """ read_func_wrapper reads the attribute value, stores it and returns it" diff --git a/attribute_wrapper/decorators.py b/attribute_wrapper/decorators.py deleted file mode 100644 index 1fa4af7..0000000 --- a/attribute_wrapper/decorators.py +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright (C) 2022 ASTRON (Netherlands Institute for Radio Astronomy) -# SPDX-License-Identifier: Apache-2.0 - -import logging -from functools import wraps - -__all__ = ["fault_on_error"] - -logger = logging.getLogger() - - -def fault_on_error(): - """Wrapper to catch exceptions. Sets the device in a FAULT state if any occurs.""" - - def inner(func): - @wraps(func) - def error_wrapper(device, *args, **kwargs): - try: - return func(device, *args, **kwargs) - except Exception as e: - logger.exception("Function failed.") - device.Fault(f"FAULT in {func.__name__}: {e.__class__.__name__}: {e}") - raise - - return error_wrapper - - return inner -- GitLab