Description of problem: Due to the unordered nature of sets, it is possible for signal handlers like _gracefull_shutdown() to run first and clear the _signal_handlers before other registered handlers have run. Version-Release number of selected component (if applicable): 17.1.3 How reproducible: Randomly reproducible with a service launched with ServiceLauncher-launched service that calls SignalHandler.add_handler() Steps to Reproduce: import eventlet; eventlet.monkey_patch() import os import signal import sys import time from oslo_config import cfg from oslo_service import service def one(*args): print("one") def two(*args): print("two") def three(*args): print("three") class MyService(service.Service): def start(self): sh = service.SignalHandler() sh.add_handler("SIGTERM", one) sh.add_handler("SIGTERM", two) sh.add_handler("SIGTERM", three) def wait(self): os.kill(os.getpid(), signal.SIGTERM) class MySL(service.ServiceLauncher): def _graceful_shutdown(self, *args, **kwargs): print("graceful") res = super()._graceful_shutdown(*args, **kwargs) return res s = MyService() l = MySL(cfg.CONF) l.launch_service(s) l.wait() Actual results: Signals are executed in an undefined order. Expected results: Signals are executed in a defined order, LIFO. (three, two, one, graceful) Additional info:
Thanks for the heads up, I think it is worth backporting your patch (https://review.opendev.org/c/openstack/oslo.service/+/911627) to stable branches.
Assigning this BZ to Daniel who is our upstream Oslo release liaison. Daniel (mbollo) is be able to backport (upstream and downstream) and Daniel is granted to release this fix. I'm not anymore the release liaison of Oslo so I'm not anymore granted to propose releases for Oslo.
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory (RHOSP 17.1.4 bug fix and enhancement advisory), and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHBA-2024:9973