Skip to content

Commit

Permalink
Merge pull request #89 from kentbull/cleanup-sigint-handler
Browse files Browse the repository at this point in the history
refactor: remove redundant SigInt handler
  • Loading branch information
kentbull authored Jan 13, 2025
2 parents 5b53bdc + 0d71219 commit a51a698
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/vlei/app/shutdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
class GracefulShutdownDoer(doing.Doer):
"""
Shuts all Agency agents down before exiting the Doist loop, performing a graceful shutdown.
Sets up signal handlers in the Doer.enter lifecycle method and exits the Doist scheduler loop in Doer.exit
Checks for the signals in the Doer.recur lifecycle method.
Sets up signal handler in the Doer.enter lifecycle method and exits the Doist scheduler loop in Doer.exit
Checks for the shutdown flag in the Doer.recur lifecycle method.
"""
def __init__(self, doist, **kwa):
"""
Expand All @@ -27,19 +27,13 @@ def handle_sigterm(self, signum, frame):
logger.info(f"Received SIGTERM, initiating graceful shutdown.")
self.shutdown_received = True

def handle_sigint(self, signum, frame):
"""Handler function for SIGINT"""
logger.info(f"Received SIGINT, initiating graceful shutdown.")
self.shutdown_received = True

def enter(self):
"""
Sets up signal handlers.
Lifecycle method called once when the Doist running this Doer enters the context for this Doer.
"""
# Register signal handler
signal.signal(signal.SIGTERM, self.handle_sigterm)
signal.signal(signal.SIGINT, self.handle_sigint)
logger.info("Registered signal handlers for SIGTERM and SIGINT")

def recur(self, tock=0.0):
Expand Down

0 comments on commit a51a698

Please sign in to comment.