Skip to content
Snippets Groups Projects
Commit b78a2145 authored by Jan David Mol's avatar Jan David Mol
Browse files

Merge branch 'dont-fault-on-read-write-error' into 'main'

Do not go to FAULT on a read error

See merge request !11
parents 6623e044 d07c93ae
No related branches found
No related tags found
1 merge request!11Do not go to FAULT on a read error
Pipeline #117318 failed
......@@ -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
......@@ -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"
......
# 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment