From 8a5852ae2018b0aa4733d0665082ee3a83cc67c5 Mon Sep 17 00:00:00 2001 From: David Erb Date: Wed, 10 May 2023 15:39:53 +0000 Subject: [PATCH] adds a couple exceptions, adds debug marker to signal --- src/dls_utilpack/exceptions.py | 8 ++++++++ src/dls_utilpack/signal.py | 12 ++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/dls_utilpack/exceptions.py b/src/dls_utilpack/exceptions.py index d2ef0f4..c086567 100644 --- a/src/dls_utilpack/exceptions.py +++ b/src/dls_utilpack/exceptions.py @@ -2,6 +2,14 @@ class NotFound(RuntimeError): pass +class ProgrammingFault(RuntimeError): + pass + + +class EndOfList(RuntimeError): + pass + + # When something has no value set yet. class NotSet(RuntimeError): pass diff --git a/src/dls_utilpack/signal.py b/src/dls_utilpack/signal.py index 8af0a97..90bec5d 100644 --- a/src/dls_utilpack/signal.py +++ b/src/dls_utilpack/signal.py @@ -25,14 +25,14 @@ def __init__(self, signum): def _signal_handler(self, sig, frame): self._count += 1 logger.debug( - "signum %d happened, count is now %d" % (self._signum, self._count) + "[DLSSIG] signum %d happened, count is now %d" % (self._signum, self._count) ) if ( self._auto_deactivate_count is not None and self._count >= self._auto_deactivate_count ): logger.debug( - "signum %d auto deactivate count %d reached" + "[DLSSIG] signum %d auto deactivate count %d reached" % (self._signum, self._auto_deactivate_count) ) self.deactivate() @@ -41,12 +41,12 @@ def _signal_handler(self, sig, frame): def activate(self, auto_deactivate_count=None): self._auto_deactivate_count = auto_deactivate_count self._original = signal.signal(self._signum, self._signal_handler) - # logger.debug("signum %d original handler %s replaced by %s" % (self._signum, id(self._original), id(self._signal_handler))) + # logger.debug("[DLSSIG] signum %d original handler %s replaced by %s" % (self._signum, id(self._original), id(self._signal_handler))) if self._auto_deactivate_count is None: - logger.debug("signum %d activated" % (self._signum)) + logger.debug("[DLSSIG] signum %d activated" % (self._signum)) else: logger.debug( - "signum %d activated to auto deactivate at count %s" + "[DLSSIG] signum %d activated to auto deactivate at count %s" % (self._signum, self._auto_deactivate_count) ) @@ -56,7 +56,7 @@ def deactivate(self): # original_id = id(self._original) signal.signal(self._signum, self._original) self._original = None - # logger.debug("signum %d deactivated, restoring original handler %s" % (self._signum, original_id)) + # logger.debug("[DLSSIG] signum %d deactivated, restoring original handler %s" % (self._signum, original_id)) # ----------------------------------------------------------------- def is_active(self):