Skip to content

Commit

Permalink
adds a couple exceptions, adds debug marker to signal
Browse files Browse the repository at this point in the history
  • Loading branch information
David Erb committed May 10, 2023
1 parent 73f31fb commit 8a5852a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
8 changes: 8 additions & 0 deletions src/dls_utilpack/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions src/dls_utilpack/signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
)

Expand All @@ -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):
Expand Down

0 comments on commit 8a5852a

Please sign in to comment.