diff --git a/sonic-ledd/scripts/ledd b/sonic-ledd/scripts/ledd index 8e813bea55dd..75a1d7e690a6 100644 --- a/sonic-ledd/scripts/ledd +++ b/sonic-ledd/scripts/ledd @@ -50,6 +50,8 @@ REDIS_HOSTNAME = "localhost" REDIS_PORT = 6379 REDIS_TIMEOUT_USECS = 0 +SELECT_TIMEOUT = 1000 + #========================== Syslog wrappers ========================== def log_info(msg): @@ -204,7 +206,13 @@ def main(): # Listen indefinitely for changes to the PORT table in the Application DB while True: - (state, c) = sel.select() + # Use timeout to prevent ignoring the signals we want to handle + # in signal_handler() (e.g. SIGTERM for graceful shutdown) + (state, c) = sel.select(SELECT_TIMEOUT) + + if state == swsscommon.Select.TIMEOUT: + # Do not flood log when select times out + continue if state != swsscommon.Select.OBJECT: log_warning("sel.select() did not return swsscommon.Select.OBJECT") continue