Skip to content

Commit

Permalink
[ledd] Use select() with timeout for AppDB notifications (sonic-net#16)
Browse files Browse the repository at this point in the history
Otherwise ledd ignores signals other than SIGKILL making impossible to
use __del__() destructors in LedClass implementations and delays pmon
docker container shutdown up to 10s.

Signed-off-by: Sergey Popovich <sergey.popovich@ordnance.co>
  • Loading branch information
serhepopovych authored and jleveque committed May 31, 2018
1 parent 6d35814 commit ce83d58
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion sonic-ledd/scripts/ledd
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ REDIS_HOSTNAME = "localhost"
REDIS_PORT = 6379
REDIS_TIMEOUT_USECS = 0

SELECT_TIMEOUT = 1000

#========================== Syslog wrappers ==========================

def log_info(msg):
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ce83d58

Please sign in to comment.